Selecting first and last row in a range

Mondi_2000

New Member
Joined
May 4, 2017
Messages
7
Hi Forum,
I am trying to select a range of rows in a spreadsheet, via a macro.
My macro button is in the London 2017 cell.
Once I click on the button I'd like the macro to select Rows 2 to 5
Rows 2-5 are empty so I'm sure the code will include Select XLDown but that selects Row 6
I would like to use the same code to be able to select Rows 7 to 8 etc etc
I've looked at so much code but I've not found anything to help me.. I'm not trained in VBA so simple is best :rolleyes:
Thank you in advance
Raymond


1 London20172018
21020
31020
41020
51020
6 New York20172018
71020
81020
9 Sydney20172018

<tbody>
</tbody>
 
Yes, if there is DATA in 2, then select 2:5.. then I click on New York and it selects 7:8 (even if there is no data in 7...)
Okay, I am a little unsure about your data layout...

1) In Message #1, you show more data on the same row as your Column A entries; however, in Message #6, you show the Column A items on the row all by themselves (no other data on the row). Which is it (the actual arrangement of your data dictates how to write the code)?

2) In Message #6, you show a blank row under the LARKHILL item... do you actually have such blank rows scattered throughout your data?
 
Upvote 0

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.
Rick, the blank row under LARKHILL is an error.. the layout is as per #6.
However, the VBA you previously provided does work, as long as I click in the cell that has the last complete entry in it - this selects data to the last blank cell and selects the appropriate rows (from top to bottom).
The next stage is to sort the Rows by date (which is in another column) but the code I have (recorded in a macro) embeds the row numbers in it.
What I need is to have excel select the rows at the end of your code and with those rows selected perform the sort... I can't have the rows numbers embedded in the VBA, as it won't work on other parts of the spreadsheet.
It used to be called "with.selection" or similar.
Thanks Rick
 
Upvote 0

Forum statistics

Threads
1,215,566
Messages
6,125,593
Members
449,237
Latest member
Chase S

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