VBA ERROR IN READING THE SHEET

blackorchids2002

Board Regular
Joined
Dec 29, 2011
Messages
138
Hello Masters,

I am having an error bellow when using a command button.

My starting point is in Sheet 2. I want to get the last row that has a record in Sheet 1 but it continue to read the last row in Sheet 2.

Sheet 1 is my raw data
Sheet 2 is my report and has list on it.


Private Sub CommandButton1_Click()

Dim Last_Row As Long
Dim mmraw As Worksheet

Set mmraw = Sheets("Excel Report")
mmraw.Select
mmraw.Cells(1, 1).Select
Set mmraw = ActiveSheet
With ActiveSheet
Last_Row = Cells(Rows.Count, 1).End(xlUp).Row
MsgBox Last_Row
End With
End Sub

Thanks :)
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
What is the name of Sheet1?
 
Upvote 0
Hi

Last_Row = Name Off Sheet as Fluff recommend .Cells(Rows.Count, 1).End(xlUp).Row
 
Last edited:
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,168
Members
448,870
Latest member
max_pedreira

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