PC Review


Reply
Thread Tools Rate Thread

Re: Check Worksheet Name and Select if Meets Criteria

 
 
David Heaton
Guest
Posts: n/a
 
      11th Aug 2009
On Aug 11, 8:17*am, ainbinder <aainbin...@gmail.com> 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


Try this
Sub SelectCockpit()

Dim Datasheets() As String
Dim shtCount As Integer
For Each wkssheet In Worksheets
If Left(wkssheet.Name, 4) = "Data" Then
ReDim Preserve Datasheets(shtCount)
Datasheets(shtCount) = wkssheet.Name
shtCount = shtCount + 1
End If
Next wkssheet
Sheets(Datasheets).Select

End Sub
 
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 Dave Peterson Microsoft Excel Discussion 0 11th Aug 2009 02:50 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 02:53 AM.