How to select full range in excel vba -
when debugging excel-vba program came know data range not selected.
below picture shows data's model , problem. 
i used code select whole range. not working properly.
dim rngtemp range set rngtemp = cells.find("*", searchorder:=xlbyrows, searchdirection:=xlprevious) rngtemp please me giving code selecting whole range given in figure above.
in code searching xlbyrows. , hence getting address of last cell has data g7.
further comment, trying?
sub sample() dim lastrow long, lastcol long dim rng range sheets("sheet1") '<~~ change relevant sheet if application.worksheetfunction.counta(.cells) <> 0 lastrow = .cells.find(what:="*", _ after:=.range("a1"), _ lookat:=xlpart, _ lookin:=xlformulas, _ searchorder:=xlbyrows, _ searchdirection:=xlprevious, _ matchcase:=false).row lastcol = .cells.find(what:="*", _ after:=.range("a1"), _ lookat:=xlpart, _ lookin:=xlformulas, _ searchorder:=xlbycolumns, _ searchdirection:=xlprevious, _ matchcase:=false).column else lastrow = 1: lastcol = 1 end if set rng = .range("a1:" & _ split(.cells(, lastcol).address, "$")(1) & _ lastrow) msgbox rng.address end end sub
Comments
Post a Comment