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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
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,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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