Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Select Sheets via Array Macro

For educational purposes,I'm am trying to create a macro
to use in an add-in that will select all of the sheets in
a workbook via use of an array. This macro will work in
the current workbook but does not seem to work when
applied to other workbooks. Would anyone have advice on
how this macro could be modified so that it could be
placed in the add-in and works when applied to other
workbooks?

Sub TestSelect()
Dim Sht() As String
Dim Cnt As Long
ReDim Sht(1 To ThisWorkbook.Sheets.Count)
For Cnt = LBound(Sht) To UBound(Sht)
ThisWorkbook.Sheets.Select
Next Cnt
End Sub

Thanks for your help.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Select Sheets via Array Macro

thisworkbook refers to the addin (the workbook containing the code)

If you are going to do Sheets.Select, there is no reason to loop.


Sub TestSelect()
ActiveWorkbook.sheets.Select
end Sub

--
Regards,
Tom Ogilvy

"Frank" wrote in message
...
For educational purposes,I'm am trying to create a macro
to use in an add-in that will select all of the sheets in
a workbook via use of an array. This macro will work in
the current workbook but does not seem to work when
applied to other workbooks. Would anyone have advice on
how this macro could be modified so that it could be
placed in the add-in and works when applied to other
workbooks?

Sub TestSelect()
Dim Sht() As String
Dim Cnt As Long
ReDim Sht(1 To ThisWorkbook.Sheets.Count)
For Cnt = LBound(Sht) To UBound(Sht)
ThisWorkbook.Sheets.Select
Next Cnt
End Sub

Thanks for your help.



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
Macro to select all sheets belvy123 Excel Discussion (Misc queries) 7 March 27th 08 09:43 PM
macro to select all sheets belvy123 Excel Discussion (Misc queries) 1 March 26th 08 04:23 PM
Macro to select and print sheets JoeP Excel Discussion (Misc queries) 3 April 19th 07 06:44 PM
sheets(array).select problem Mark Excel Discussion (Misc queries) 5 January 26th 07 04:11 PM
Select sheets from an array for printing bennyob Excel Discussion (Misc queries) 2 November 24th 05 01:03 PM


All times are GMT +1. The time now is 04:20 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"