VBA Error

mgirvin

Well-known Member
Joined
Dec 15, 2005
Messages
1,248
Office Version
  1. 365
Platform
  1. Windows
Dear Excel Team,

I am new to VBA. I am reading the Mr Excel VBA book. I have defined a variable:

FinalRow = Cells(65530, 2).End(x1Up).Row

Every time I hit F8 and Execute, I get Error "Run time error 1004, Application-defined or object-defined error". I am pretty sure the problem is with the ".End(x1up)", however, this is how it is typed in the book.

The whole code is this:

'Test FinalRow
'by Gel 8/25/06
Sub TestFinalRow()
FinalRow = Cells(65530, 2).End(x1Up).Row

For i = 2 To FinalRow
If Cells(i, 2).Value > 0 Then
Cells(i, 2).Interior.ColorIndex = 6
End If
Next i

End Sub

Sincerely, Mike Gel Girvin
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Dear Excel Team,

Yes, I tried it just to see if it could be done! I can't imagine needing 64!

Although... I have seen some ingenuous interest calculating formulas that used many IFs concatenated together (more than 7). In addition, before I knew how to use the OFFSET function, I had 30 IFs strung together to show the running Ledger balance at the bottom of the sheet.

Rest assured that there will be some that max out the 64 limit for both IF and Conditional Formatting soon after its release!
 
Upvote 0

Forum statistics

Threads
1,226,220
Messages
6,189,697
Members
453,565
Latest member
Mukundan

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