Set Range using column and row numbers in VBA - not working

JAzzyD

New Member
Joined
Aug 31, 2016
Messages
5
I have VBA code that sets the range as
Set SCHOOLYRRANGE = .Range("L:L")

and this works fine...

I would like to set SCHOOLYRRANGE using column and row numbers
I tried
Set SCHOOLYRRANGE = .Range(Cells(12, 4), Cells(12, 77333))

77333 is the last row
4 is row where data starts, header is in L3

Thanks. Probably something obvious...
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Try something like this:-
NB:- Notice Dots in code !!!!
Code:
Dim SCHOOLYRRANGE As Range
With Sheets("Sheet1")
    Set SCHOOLYRRANGE = .Range(.Cells(4, 12), .Cells(77333, 12))
End With
MsgBox SCHOOLYRRANGE.Address(external:=True)
 
Upvote 0
Thank you that works perfectly.
I did solve it by using:
Set SCHOOLYRRANGE = .Range(Cells(4, 12).Address & ":" & Cells(77333, 12).Address)
but your code is much better and concise...

Thanks again
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,298
Members
449,077
Latest member
Rkmenon

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