#1   Report Post  
Dr.Schwartz
 
Posts: n/a
Default Selecting sheets

How can make my code add a sheet to a selection?

Something like:

Dim WSName As Worksheet
For Each WSName In Worksheets
If Left(WSName.Name, 3) = "Pre" Then
'the code for adding the sheet to the selection
End If
Next

Thanks
The Doctor
  #2   Report Post  
FSt1
 
Posts: n/a
Default

hi,

Sheets.add would add a sheet to the workbook but i'm not sure if this is
what you want. could you clairify.


FSt1

"Dr.Schwartz" wrote:

How can make my code add a sheet to a selection?

Something like:

Dim WSName As Worksheet
For Each WSName In Worksheets
If Left(WSName.Name, 3) = "Pre" Then
'the code for adding the sheet to the selection
End If
Next

Thanks
The Doctor

  #3   Report Post  
KL
 
Posts: n/a
Default

Maybe something like this:

Sub test()
Dim temp As Variant, WSName As Worksheet
ReDim temp(0)
For Each WSName In Worksheets
If Left(WSName.Name, 3) = "Pre" Then
temp(UBound(temp)) = WSName.Name
ReDim Preserve temp(UBound(temp) + 1)
End If
Next WSName
ReDim Preserve temp(UBound(temp) - 1)
Sheets(temp).Select
End Sub

Regards,
KL

"Dr.Schwartz" wrote in message
...
How can make my code add a sheet to a selection?

Something like:

Dim WSName As Worksheet
For Each WSName In Worksheets
If Left(WSName.Name, 3) = "Pre" Then
'the code for adding the sheet to the selection
End If
Next

Thanks
The Doctor



  #4   Report Post  
Dr.Schwartz
 
Posts: n/a
Default

I simply want to select all sheets where the first three letters of the sheet
name is "Pre".

Manually I just left mouse click on the sheet tabs I want to select while
pressing Ctrl.

"FSt1" wrote:

hi,

Sheets.add would add a sheet to the workbook but i'm not sure if this is
what you want. could you clairify.


FSt1

"Dr.Schwartz" wrote:

How can make my code add a sheet to a selection?

Something like:

Dim WSName As Worksheet
For Each WSName In Worksheets
If Left(WSName.Name, 3) = "Pre" Then
'the code for adding the sheet to the selection
End If
Next

Thanks
The Doctor

  #5   Report Post  
Bob Phillips
 
Posts: n/a
Default

Dim sSheets As String
Dim cSheets As Long
Dim sh As Worksheet

ReDim arySheets(1 To 1)
For Each sh In ActiveWorkbook.Worksheets
If Left(sh.Name, 3) = "Pre" Then
sSheets = sSheets & sh.Name & ","
End If
Next sh

sSheets = Left(sSheets, Len(sSheets) - 1)
Worksheets(Split(sSheets, ",")).Select


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Dr.Schwartz" wrote in message
...
I simply want to select all sheets where the first three letters of the

sheet
name is "Pre".

Manually I just left mouse click on the sheet tabs I want to select while
pressing Ctrl.

"FSt1" wrote:

hi,

Sheets.add would add a sheet to the workbook but i'm not sure if this is
what you want. could you clairify.


FSt1

"Dr.Schwartz" wrote:

How can make my code add a sheet to a selection?

Something like:

Dim WSName As Worksheet
For Each WSName In Worksheets
If Left(WSName.Name, 3) = "Pre" Then
'the code for adding the sheet to the selection
End If
Next

Thanks
The Doctor



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
Copying multiple sheets from one book 2 another and undertake spec Pank Mehta Excel Discussion (Misc queries) 14 March 16th 05 04:41 PM
calculating excel spreadsheet files for pensions and life insurance (including age calculation sheets) RICHARD Excel Worksheet Functions 1 March 15th 05 05:49 PM
To data apearing in other sheets I can use =SUM(. How I can have . KP Excel Worksheet Functions 1 January 18th 05 11:28 PM
PROTECTING/UNPROTECTING SHEETS Maureen Excel Discussion (Misc queries) 1 January 6th 05 06:46 PM
Multiple sheets selected twa14 Excel Discussion (Misc queries) 2 December 21st 04 11:15 AM


All times are GMT +1. The time now is 04:12 AM.

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"