Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Excel macros VBA
i want to find the last empty row for a particular coulmn like A coulmn .
 

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 25-Oct-12 22:12pm
aksh619297
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Some suggested solutions here[^].
  Permalink  
Comments
aksh619 at 26-Oct-12 8:14am
   
Thanks mate ..
Maciej Los at 1-Nov-12 15:46pm
   
Answer is good, but examples are... ;)
Richard MacCutchan at 1-Nov-12 20:53pm
   
What?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You can use function, like this:
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:
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")
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 210
2 BillWoodruff 205
3 DamithSL 165
4 Tomas Takac 144
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 1 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100