The following function is something that I've amended from
Walkenbach's book (I think). It gives the last used row in a
particular column. As I recollect, Walkenbach's code is more compact
(and works perfectly of course) but is harder to understand.
So to run the following function, you'd maybe put something like:
dim mysheet as worksheet
set mysheet=activeworkbook.worksheets("Sheet1")
mysheet.cells(ColumnLast(mysheet,7),7).activate
.....
Function ColumnLast(inputsheet as worksheet,colnum as integer) as
integer
Dim rng1 as range,rng2 as range, rng3 as range
Dim collen as integer, i as integer
set rng1 = inputsheet.columns(colnum)
set rng2 = inputsheet.usedrange
set rng3 = intersect(rng1,rng2)
collen=rng3.count
for i=collen to 1 step -1
if not IsEmpty(rng3(i)) then
ColumnLast = i+1
Exit Function
next i
columnlast=1
end function