Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default With Sheets("wildcard")

How can I use a wildcard in a With Sheets statement? I have written a macro
that works on sheet ScoreCard. However, during the export process if the end
user saves the workbook rather than open it ScoreCard is changed to
ScoreCard.Bob or ScoreCard.Alice. I need to do something like this to make
the macro work

With Sheets("ScoreCard*")

but that doesn't work. Ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default With Sheets("wildcard")

dim ws as worksheet
for each ws in Worksheets




On 5 May, 17:44, Bishop wrote:
How can I use a wildcard in a With Sheets statement? *I have written a macro
that works on sheet ScoreCard. *However, during the export process if the end
user saves the workbook rather than open it ScoreCard is changed to
ScoreCard.Bob or ScoreCard.Alice. *I need to do something like this to make
the macro work

With Sheets("ScoreCard*")

but that doesn't work. *Ideas?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default With Sheets("wildcard")

Sorry, posting trouble: try something like

Dim ws as Worksheet
For Each ws in Worksheets
If ws.Name like "ScoreCard*" Then
With ws
' do your stuff
End With
End If
Next



On 5 May, 17:44, Bishop wrote:

How can I use a wildcard in a With Sheets statement? *I have written a macro
that works on sheet ScoreCard. *However, during the export process if the end
user saves the workbook rather than open it ScoreCard is changed to
ScoreCard.Bob or ScoreCard.Alice. *I need to do something like this to make
the macro work


With Sheets("ScoreCard*")

but that doesn't work. *Ideas?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default With Sheets("wildcard")

When I do this for myself, I usually just activate the correct sheet first.

If I do it for others, I tell them to activate the correct sheet first.

Then I can use:

with activesheet

If I want a reminder, I'll add this kind of stuff near the top:

Dim Resp as long

resp = Msgbox(Prompt:="do you want to run the macro against this sheet", _
buttons:=vbyesno)

if resp = vbno then
exit sub
end if

with activesheet
....

Bishop wrote:

How can I use a wildcard in a With Sheets statement? I have written a macro
that works on sheet ScoreCard. However, during the export process if the end
user saves the workbook rather than open it ScoreCard is changed to
ScoreCard.Bob or ScoreCard.Alice. I need to do something like this to make
the macro work

With Sheets("ScoreCard*")

but that doesn't work. Ideas?


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default With Sheets("wildcard")

You could use something like this...

Dim sht As Worksheet
For Each sht In ActiveWorkbook.Sheets
If Left(sht.Name, 9) = "ScoreCard" Then
With sht
'do something
End With
End If
Next sht

Hope this helps,

Hutch

"Bishop" wrote:

How can I use a wildcard in a With Sheets statement? I have written a macro
that works on sheet ScoreCard. However, during the export process if the end
user saves the workbook rather than open it ScoreCard is changed to
ScoreCard.Bob or ScoreCard.Alice. I need to do something like this to make
the macro work

With Sheets("ScoreCard*")

but that doesn't work. Ideas?



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
COUNTIFS equivalent in Excel 2003 - both criteria have text, one has "wildcard" Courtney[_3_] Excel Worksheet Functions 3 April 20th 10 03:01 AM
"For each w in workbooks "can't find ".dat" open excel sheets, Ricky Excel Programming 1 October 23rd 09 06:00 AM
SHEE1. Duplicate all sheets, making 2 copies of ea. / 2. Add " E"and " F" to end of tab name. / 3. Put all sheets at the very end. StargateFanNotAtHome[_2_] Excel Programming 3 September 4th 09 04:02 PM
"Find" a wildcard as a place marker and "replace" with original va Eric Excel Discussion (Misc queries) 1 January 27th 09 06:00 PM
Whats wrong with this? MyWBAccRep.Sheets("Volumes").Cells.Find("latest").Copy.Offset(0, Simon[_2_] Excel Programming 2 August 11th 08 01:29 PM


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