PC Review


Reply
Thread Tools Rate Thread

Re: Check Worksheet Name and Select if Meets Criteria

 
 
Dave Peterson
Guest
Posts: n/a
 
      11th Aug 2009
One more.

Option Explicit
Sub SelectCockpit()

Dim wksSheet As Worksheet
Dim iCtr As Long
Dim WksNames() As String

ReDim WksNames(1 To Worksheets.Count)

iCtr = 0
For Each wksSheet In Worksheets
If LCase(Left(wksSheet.Name, 4)) = LCase("Data") Then
If wksSheet.Visible = xlSheetVisible Then
iCtr = iCtr + 1
WksNames(iCtr) = wksSheet.Name
End If
End If
Next wksSheet

If iCtr = 0 Then
MsgBox "no sheet names qualify!"
Else
ReDim Preserve WksNames(1 To iCtr)
Worksheets(WksNames).Select
End If

End Sub



ainbinder wrote:
>
> Hi everyone, i have what i think is a very easy question. I'm trying
> to select all the worksheets in my workbook that start with the
> "Data". i wrote this vba code, and even though i put a watch on the
> left formula and it shows "Data" in the watch window, it never selects
> the sheet. Any help would be much appreciated!!!!
>
> Sub SelectCockpit()
> '
> ' Selects all tabs with cockpit in first 6 digits
>
> Dim wksSheet As Worksheet
>
> Sheets(1).Activate
> For Each wksSheet In Worksheets
> If Left(wksSheet.Name, 4) = "Data" Then
> wksSheet.Select
> End If
> Next wksSheet
> End Sub


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Check Worksheet Name and Select if Meets Criteria David Heaton Microsoft Excel Discussion 0 11th Aug 2009 02:06 AM
Populate worksheet with data that meets date range criteria P0llyW0G Microsoft Excel Worksheet Functions 3 28th Sep 2008 10:01 PM
If message meets criteria the automatically tick check box in Acce ant1983 Microsoft Outlook VBA Programming 1 25th Mar 2008 06:30 AM
If Outlook message meets criteria then tick check-box in my db ant1983 Microsoft Access VBA Modules 0 21st Mar 2008 07:34 PM
HELP! Change color of a control if criteria meets criteria in an unbound box Aileen Microsoft Access Forms 1 26th Sep 2003 07:49 PM


Features
 

Advertising
 

Newsgroups
 


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