Find last used row in a column (not in the whole worksheet)
dim myCol as long
dim LastRow as long
mycol = 123 'an example
lastrow = -1 'never happen in excel!
with activesheet
if application.counta(.cells(1,mycol).entirecolumn) = 0 then
msgbox "the column is empty"
else
lastrow = .cells(.rows.count,mycol).end(xlup).row
msgbox lastrow
end if
end with
" wrote:
Hi all,
I was wondering if you can help me with this:
I need to:
1) identify the last used row in a column (not in the whole worksheet)
2) identify whether a column is blank or not
The two are of course related - if I figure out for the 1st point,
then the other is straightforward.
Any suggestions?
Thanks in advance!
PS I use Excel 2007
--
Dave Peterson
|