Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How to Create an array

I would like to Create an array containing Sheets(3) to Sheets.Count
Is this possible .. if so please advise

Regards & TIA


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default How to Create an array

On Feb 2, 9:16 am, "JB" wrote:
I would like to Create an array containing Sheets(3) to Sheets.Count
Is this possible .. if so please advise

Regards & TIA


You already have a built in "array" with the Worksheets collection.
Create a worksheet variable and use that to cycle through the
collection using the For Each construct. I.e.,

Sub SheetDiddle()
Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets
If ws.Index = 3 Then
' Do something here
End If
Next

End Sub


SteveM
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How to Create an array


"SteveM" wrote in message
...
On Feb 2, 9:16 am, "JB" wrote:
I would like to Create an array containing Sheets(3) to Sheets.Count
Is this possible .. if so please advise

Regards & TIA


You already have a built in "array" with the Worksheets collection.
Create a worksheet variable and use that to cycle through the
collection using the For Each construct. I.e.,

Sub SheetDiddle()
Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets
If ws.Index = 3 Then
' Do something here
End If
Next

End Sub


SteveM


Hmmm ... what I was hoping to do was group the worksheets together and then
print them in one operation

Is this possible


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How to Create an array

I think this is how I should do it ... but need to add sheets up to
Sheets.Count

Sheets(Array(3, 4, 5, 6)).PrintOut


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default How to Create an array

Dim i as Long
ReDim arr(3 To ActiveWorkbook.Sheets.Count)
For i = 3 To UBound(arr)
arr(i) = i
Next
ActiveWorkbook.Sheets(arr).Printout

Assumes of course at least 3 sheets.

Regards,
Peter T

"JB" wrote in message
...
I think this is how I should do it ... but need to add sheets up to
Sheets.Count

Sheets(Array(3, 4, 5, 6)).PrintOut






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How to Create an array

Got it now ... Thanks for your input

"Peter T" <peter_t@discussions wrote in message
...
Dim i as Long
ReDim arr(3 To ActiveWorkbook.Sheets.Count)
For i = 3 To UBound(arr)
arr(i) = i
Next
ActiveWorkbook.Sheets(arr).Printout

Assumes of course at least 3 sheets.

Regards,
Peter T

"JB" wrote in message
...
I think this is how I should do it ... but need to add sheets up to
Sheets.Count

Sheets(Array(3, 4, 5, 6)).PrintOut






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How to Create an array

Try

Dim Arr() As String
Dim N As Long
With ThisWorkbook.Worksheets
ReDim Arr(1 To .Count)
For N = 1 To .Count
Arr(N) = .Item(N).Name
Next N
End With


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2008
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


"JB" wrote in message
...
I would like to Create an array containing Sheets(3) to Sheets.Count
Is this possible .. if so please advise

Regards & TIA



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How to Create an array

Thanks Chip ... exactly what I requied

"Chip Pearson" wrote in message
...
Try

Dim Arr() As String
Dim N As Long
With ThisWorkbook.Worksheets
ReDim Arr(1 To .Count)
For N = 1 To .Count
Arr(N) = .Item(N).Name
Next N
End With


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2008
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


"JB" wrote in message
...
I would like to Create an array containing Sheets(3) to Sheets.Count
Is this possible .. if so please advise

Regards & TIA





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
create array Al[_19_] Excel Programming 6 July 13th 07 08:29 PM
How do you create an Array of Arrays? NickHK Excel Programming 0 December 22nd 06 02:03 AM
Using Loop to create Array davidm Excel Programming 4 June 15th 05 11:41 AM
how do I create an array lost Excel Discussion (Misc queries) 6 April 7th 05 12:43 AM
how do I create an array array_deficient Excel Discussion (Misc queries) 0 April 6th 05 09:53 PM


All times are GMT +1. The time now is 05:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"