Find LastRow Excel to Calc

Roderick_E

Well-known Member
Joined
Oct 13, 2007
Messages
2,051
Ugh,
I rely on the bit of code below all the time to find the last cell but the problem is, my company has some people using Excel & some using OpenOffice Calc.

1 Dim LastRow As Long, i As Long
2 LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
3 For i = LastRow To 6 Step -1 'row 5, in this case is the header row.
4 With Rows(i)
5 'do stuff here
6 End With
7 Next i

Calc doesn't like line 2 & crashes. (object issues) Does anyone have a simple piece of OpenOffice code that will do this same thing? Thanks.

P.S.
Oh it would be cool too if someone had a bit of code that I can place in ALL of my macros that first determined if the person was running the macro under Excel or OpenOffice, that way I could call the appropriate macros

Thanks
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,215,053
Messages
6,122,888
Members
449,097
Latest member
dbomb1414

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