Select Range of Cells - Gone blank

GiraffetheGeek

Board Regular
Joined
May 25, 2011
Messages
58
Hi there,

I am a beginner with VB so forgive me is this is an elementary error

I have gone blank. I've sat here for the last 15 minutes and for the life of me cannot remember how to do this.

I am trying to get VB to select a range of cell relative to two named cells.

I have used this

Code:
Range("TitleRow").Offset(1,0):Range("LastRow").Offset(-1,14).Select

This obviously is wrong, but I cannot remember the correct way to do this.

I want it to select the range of cells 1 below the cell named TitleRow over to the cell 1 above and 14 to the right of the cell "LastRow".

Once I get this working the offset values will change depending on a value selected in another cell by the user, but it's just this line that is bafflling me.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Code:
    Range(Range("TitleRow").Offset(1, 0), Range("LastRow").Offset(-1, 14)).Select
 
Upvote 0
Are you calling out what TitleRow and LastRow are? Depending on your active range, and if the data is coniguous:

Sub LstRow()
Dim LastRow As Long
ActiveCell.End(xlDown).Select
LastRow = ActiveCell.Row
Range("A1:N" & LastRow ).Select
End Sub

If it's not contiguous swap out the ActiveCell.End(xlDown).Select line with

Range("A60000").End(xlUp).Select
 
Upvote 0
Thanks shg, thats the change I needed to make. Looking at it now it seems simple!!

Sorry andiemac being new to vb I didn't quite understand your code, but will keep it in mind to look at later as I progress.
 
Upvote 0
You're welcome, glad it worked for you.
 
Upvote 0

Forum statistics

Threads
1,224,579
Messages
6,179,656
Members
452,934
Latest member
mm1t1

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