Select range

  • Thread starter Thread starter Raul Sousa
  • Start date Start date
R

Raul Sousa

The following code is part of a macro.
Range("B11:" & Sheets.Count & "266").Select

My goal is to select the range B11 to AB266 or AC266 or AD266, depending on
the number of sheets.

The problem is that this code is not working, and I can’t understand why not.
 
The following code is part of a macro.  
Range("B11:" & Sheets.Count & "266").Select

My goal is to select the range B11 to AB266 or AC266 or AD266, depending on
the number of sheets.

The problem is that this code is not working, and I can’t understand whynot.

You might want to try to put in the ranges $B$11:$AB$266.
The $ sign keeps the range as is.

Hope this helps
 
Hi,

One way. You will need to change the sheets to the correct number and
perhaps include a Case Else if none of the conditions are met.

Sub prime()
Select Case Worksheets.Count
Case Is = 3
mycolumn = "AB"
Case Is = 4
mycolumn = "AC"
Case Is = 5
mycolumn = "AD"
End Select
Range("B11:" & mycolumn & "266").Select
End Sub

Mike
 
Range("B11:AB266").Resize(,Sheets.Count)Select

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Just make a nice string to give to the RANGE() function:

Sub raul()
s = Cells(11, "B").Address & ":" & Cells(Sheets.Count, 17).Address
Range(s).Select
End Sub

I am using 17 rather than 266
 
One more:

With activesheet
.range("B11",.cells(266,sheets.count)).select
end with
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top