Number Of Rows with Data

billandrew

Well-known Member
Joined
Mar 9, 2014
Messages
743
Afternoon

Using the below to return the Number of Rows in Column B. The Column currently does not have any data, when the code is run the result is 1. Not sure why this is.

Sub CountRowsColumn()

MsgBox "Number of Rows with data in Column b is" & " " & Cells(Rows.Count, 2).End(xlUp).Row
 
Hmmm, can you run again with the code below please? (and is the sheetname correct?)

Code:
Sub test2()
MsgBox Split(Cells(Rows.Count, 2).End(xlUp).Address(external:=True), "]")(1)
End Sub
 
Last edited:
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Just one last question for tonight, does the below return nothing?

Code:
Sub test3()
MsgBox Cells(Rows.Count, 2).End(xlUp).FormulaR1C1
End Sub
 
Upvote 0
Yes it does.

Like to sincerely Thank You and the others who devoted many hours of instruction......

Cheers
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,103
Members
452,302
Latest member
TaMere

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