Range Select Question

ezywrap

New Member
Joined
Dec 15, 2005
Messages
5
Quick Question

I'm trying to select a range on a worksheet

Range("A4:BL4").Select

The above will work but I can't get the syntax correct for the code below. I'm getting an error

Runtime error 1004
Method 'Range" of object '_Global' failed

Range("'A' & y & ':BL' & y").Select

Can someone point me in the right direction ?

Thanks
 

Some videos you may like

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,946
Office Version
  1. 365
Platform
  1. Windows
Why the single quotes?

Try this.
Code:
Range("A" & y & ":BL" & y).Select
By the way you don't normally need to use select when working with ranges.
 

ezywrap

New Member
Joined
Dec 15, 2005
Messages
5
Thanks that worked

You mentioned not using Select. What would be the alternative? Would something else be faster?

I'm only selecting these columns if a condition is met and pasting them into another sheet

Thanks
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,946
Office Version
  1. 365
Platform
  1. Windows
Well it really depends on the rest of your code.
Code:
Worksheets("Sheet1").
Range("A" & y & ":BL" & y).Copy Worksheets("Sheet2").Range("A1")
Also if this condition is based on a value in a cell you could use filtering.
 

Watch MrExcel Video

Forum statistics

Threads
1,114,674
Messages
5,549,358
Members
410,910
Latest member
DessertDiva
Top