Easy VB question from newbie.

dmagnus

Board Regular
Joined
Dec 16, 2005
Messages
66
I am using the following line of code to go to the last row/column of some data in excel:

ActiveCell.SpecialCells(xlLastCell).Select

In this example, my active cell ends up being X135, though on some other sheets on which this macro will be run it could be a different row & column. All I want to do now is move the activecell to the first column of this last row - in this example, move to A135.

I think this should be easy, but I'm new and my hours of searching have come up blank. Any suggestions? Thanks, Dan
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Dan

You could perhaps use something like this.
Code:
Range("A" & ActiveCell.SpecialCells(xlLastCell).Row).Select
PS Why are you selecting anyway?
 
Upvote 0
I'm trying to find the last row of the data because I need to put three new lines of test beginning at the row just beneath the last row of the data.

I'll give your suggestion a try. Thanks.
 
Upvote 0
That code worked great. Thanks for the help. A side question, now.

The data for which I'm trying to find the last row is actually a Business Objects report(s) that I've saved as Excel. The code you provided actually takes me about 4 rows beneath the last row of data, which makes me think that for whatever reason there are 4 rows of data "observed" by Excel but no visible (probably a B.O. issue).

If I can't find a way to correct this B.O. issue, is there a way to move-up the activecell a couple of rows? I'm somewhat familiar with "offset" but don't know how/where to put it with your code.

Thanks!
 
Upvote 0
Dan

Well I don't think you actually need to select anything to do that.:)

You hardly ever need to select/activate ranges/worksheets etc.

Not 100% sure what you are trying to do but without selecting this will place test in the 3 cells below the last cell in column A.
Code:
Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(3) = "test"
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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