help to find last empty row but a bit strange

mahyr

New Member
Joined
Oct 5, 2017
Messages
5
hey
im trying to find my sheet's last empty row and place my data there. here is what i've wrote
num=Application.WorksheetFunction.CountA(Range("C:C")

i defined to search in C column but it searches A column and based on that places the datas wrong
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
I presume you are in VBA?

Code:
    Range("C1").Select    
    Selection.End(xlDown).Select
    Selection.Offset(1, 0).Select

It copies the following actions:
Go to C1
CTRL+DOWN
DOWN

Hope this helps
 
Last edited:
Upvote 0
mahyr,

Welcome to the Board.

A couple of common, reliable ways to find the last row with data...

Code:
Dim LastRow As Long
LastRow = Cells(Rows.Count, "C").End(xlUp).Row
LastRow = ActiveSheet.Cells.Find(What:="*", After:=Cells(1, 1), LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row

If you want the blank row after the LastRow, simply add 1...

Code:
LastRow = Cells(Rows.Count, "C").End(xlUp).Row + 1

Cheers,

tonyyy
 
Last edited:
Upvote 0
yeah i used this one before but i couldn't get the result i wanted till then i found the upper simpler one and that was what i wanted, so i wanted to extend it, and thanks to you, i did :)
Dim LastRow As Long
LastRow = Cells(Rows.Count, "C").End(xlUp).Row
LastRow = ActiveSheet.Cells.Find(What:="*", After:=Cells(1, 1), LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row
 
Upvote 0
@ mahyr, do you acyually want LookIn:=xlFormulas which includes formula cells returning ""? and why are you defining LastRow twice (LastRow = Cells(Rows.Count, "C").End(xlUp).Row isn't serving any purpose)?

Btw, ActiveSheet.Cells. refers to every column on the sheet and not just column C.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top