Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to find the last empty row for a particular coulmn like A coulmn .


VB
sub abc()
iRow = wkb1.Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
End Sub 

as this is taking only first coulmn and providing me with Irow = 2 but there is data present on second B coulmn .


Please help ...
thanks
aksh619
Posted

Some suggested solutions here[^].
 
Share this answer
 
Comments
aksh619 26-Oct-12 8:14am    
Thanks mate ..
Maciej Los 1-Nov-12 15:46pm    
Answer is good, but examples are... ;)
Richard MacCutchan 1-Nov-12 20:53pm    
What?
You can use function, like this:
VB
Function FirstEmptyRow(wsh As Worksheet, Optional sColName As String = "A") As Long
    FirstEmptyRow = wsh.Range(sColName & wsh.Rows.Count).End(xlUp).Row + 1
End Sub


Usage:
VB
Dim lFirstEmptyRow AS Long
'default column (A):
lFirstEmptyRow = FirstEmptyRow(ThisWorkbook.Worksheets("Sheet1"))
'or - custom column:
lFirstEmptyRow = FirstEmptyRow(ThisWorkbook.Worksheets(2), "B")
'or (using Activesheet object):
lFirstEmptyRow = FirstEmptyRow(Activesheet, "C")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900