Having trouble defining variable

FKoenig

Board Regular
Joined
Jul 27, 2011
Messages
85
Hi,

I'm brand new to Mr. Excel so try not to filet me too much if I'm dumb. My question:

I just picked up VBA AND MACROS: Microsoft Excel 2010 and am trying to follow along with some of the basic exercises. I have, however, run into an issue and I don't see what I'm doing wrong.

The book says to set a "FinalRow" variable to the last row in a worksheet.

I've retyped the code as:
FinalRow = Cells(Rows.Count, 1).End(x1Up).Row

Excel/VBA doesn't seem to like it. I get a Run-time error '1004': Application-defined or object-defined error

What am I doing wroing?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Welcome to the board...

that should be

XLUP

That's an L not the number 1.


Put this at the VERY TOP of your module, before anything else..

Option Explicit


That will help capture those misspelled words..
And it will require you to declare all variables...

Dim FinalRow As Long
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row



Hope that helps.
 
Upvote 0
You will see that throughout VBA...

Just remember who wrote the program..
xl = EXCEL
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,293
Members
452,902
Latest member
Knuddeluff

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