Excel VBA: How to define column in range with variable

simontop

New Member
Joined
Jun 7, 2011
Messages
6
Hello,
I know that with e.g. a LONG variable LastRow, I can define the last row in a range like this:

Range("A6:" & LastRow & "10")

On the other hand this does not work:

Range("A6:J" & LastColumn)

What am I doing wrong?
 
Just when I posted the question.
This seems to work but seems rather complicated:

Range(Cells(1,6), Cells(10,LastColumn))
 
Upvote 0
That's how I would've done it.

although if your first cell is A6, it should be:

Code:
Range(Cells(6,1), Cells(10,LastColumn))

Although, if the first cell won't change, you can mix it up
Code:
Range("A6", Cells(10,LastColumn))
 
Upvote 0
Thx, for some reason I can't get used to the thought, that you can mix addressing systems in VBA.

Oh and you're right about 1,6 vs. 6,1...
 
Upvote 0

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