Selecting a range in VBA when you only have row/col NUMBERS

ratbags21

New Member
Joined
Jul 13, 2006
Messages
17
We are all familiar with the statement:

Range(A1:B4).select

But what if you do not have "A1" or "B4" but numbers eg

Top left co-ordinate=1,1 and the bottom right co-ordinate=
2,4 (you get these from activecell.row or activecell.column syntax when you are navigating around the range#

How do I select a range with row & column numbers only?

Many thanks
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,303
Office Version
  1. 365
Platform
  1. Windows
You could try this.

Range(Cells(1,1), Cells(2,4)).Select

Note there could be various issues with this code depending on your other code, and also you don't generally need to select a range to work with it.
 

onlyadrafter

Well-known Member
Joined
Aug 19, 2003
Messages
5,703
Platform
  1. Windows
Hello,

something in the lines of

Code:
a = 10
b = 10
c = 12
d = 12
Cells(a, b).Select
Range(Selection, Cells(c, d)).Select
 

ratbags21

New Member
Joined
Jul 13, 2006
Messages
17
Range selection problem

You could try this.

Range(Cells(1,1), Cells(2,4)).Select

Note there could be various issues with this code depending on your other code, and also you don't generally need to select a range to work with it.

Thank you very much - this is exactly what I want!
 

Forum statistics

Threads
1,141,587
Messages
5,707,252
Members
421,498
Latest member
matinebi

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
Top