By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,961 Members | 1,320 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,961 IT Pros & Developers. It's quick & easy.

Excel Worksheet Range

P: 1
I would like to write the code to select a range of worksheets in MS Excel 07, starting with the Activesheet and ending with the last sheet.
Jan 8 '08 #1
Share this Question
Share on Google+
1 Reply


kadghar
Expert 100+
P: 1,295
I would like to write the code to select a range of worksheets in MS Excel 07, starting with the Activesheet and ending with the last sheet.
create an array with the numbers of the worksheets you want to select, or with its names.

Expand|Select|Wrap|Line Numbers
  1. Sub one()
  2. Dim i As Integer
  3. Dim a() As Integer
  4. ReDim a(Worksheets.Count - ActiveSheet.Index)
  5. For i = 0 To UBound(a)
  6.     a(i) = i + ActiveSheet.Index
  7. Next
  8. Worksheets(a).Select
  9. End Sub
Here i used the numbers, but instead you can define 'a' as a string, and put in the FOR something like:
a(i) = worksheets(i+activesheet.index).name

HTH
Jan 9 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.