Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 21
Default Using VBA select sll sheets based on Criteria on each sheet.

I know how to select all sheets but need to be able to filter which sheets I
want selected. Can I select a sheet in a workbook based on criteria in a
specific cell?

This is the code I used to select all sheets.

Dim arySheets
Dim sh
Dim i As Long

ReDim arySheets(ActiveWorkbook.Worksheets.Count - 1)

For Each sh In ActiveWorkbook.Worksheets
arySheets(i) = sh.Name
i = i + 1
Next sh
Sheets(arySheets).Select

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Using VBA select sll sheets based on Criteria on each sheet.

Try this...

Dim arySheets() as string
Dim sh as worksheet
Dim i As Long

ReDim arySheets(ActiveWorkbook.Worksheets.Count - 1)

For Each sh In ActiveWorkbook.Worksheets
if sh.range("A1").value = "Tada" then
arySheets(i) = sh.Name
i = i + 1
end if
Next sh
ReDim preserve arySheets(i-1)
Sheets(arySheets).Select

--
HTH...

Jim Thomlinson


"AirgasRob" wrote:

I know how to select all sheets but need to be able to filter which sheets I
want selected. Can I select a sheet in a workbook based on criteria in a
specific cell?

This is the code I used to select all sheets.

Dim arySheets
Dim sh
Dim i As Long

ReDim arySheets(ActiveWorkbook.Worksheets.Count - 1)

For Each sh In ActiveWorkbook.Worksheets
arySheets(i) = sh.Name
i = i + 1
Next sh
Sheets(arySheets).Select

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,934
Default Using VBA select sll sheets based on Criteria on each sheet.

Jim has given you what looks like a solution to your question... I just
wanted to point out that if you want to select all the worksheets in the
active workbook, you can use this single line of code to do that...

ActiveWorkbook.Worksheets.Select

--
Rick (MVP - Excel)


"AirgasRob" wrote in message
...
I know how to select all sheets but need to be able to filter which sheets
I
want selected. Can I select a sheet in a workbook based on criteria in a
specific cell?

This is the code I used to select all sheets.

Dim arySheets
Dim sh
Dim i As Long

ReDim arySheets(ActiveWorkbook.Worksheets.Count - 1)

For Each sh In ActiveWorkbook.Worksheets
arySheets(i) = sh.Name
i = i + 1
Next sh
Sheets(arySheets).Select


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 21
Default Using VBA select sll sheets based on Criteria on each sheet.

Hi Jim thank you for the response. I ran the code this morning and got a code
break at

ReDim Preserve arySheets(i - 1)


"Jim Thomlinson" wrote:

Try this...

Dim arySheets() as string
Dim sh as worksheet
Dim i As Long

ReDim arySheets(ActiveWorkbook.Worksheets.Count - 1)

For Each sh In ActiveWorkbook.Worksheets
if sh.range("A1").value = "Tada" then
arySheets(i) = sh.Name
i = i + 1
end if
Next sh
ReDim preserve arySheets(i-1)
Sheets(arySheets).Select

--
HTH...

Jim Thomlinson


"AirgasRob" wrote:

I know how to select all sheets but need to be able to filter which sheets I
want selected. Can I select a sheet in a workbook based on criteria in a
specific cell?

This is the code I used to select all sheets.

Dim arySheets
Dim sh
Dim i As Long

ReDim arySheets(ActiveWorkbook.Worksheets.Count - 1)

For Each sh In ActiveWorkbook.Worksheets
arySheets(i) = sh.Name
i = i + 1
Next sh
Sheets(arySheets).Select

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 21
Default Using VBA select sll sheets based on Criteria on each sheet.

Never mind I figured it out, the criteria has to be exact for example; Yes
must be Yes not YES.

"Rick Rothstein" wrote:

Jim has given you what looks like a solution to your question... I just
wanted to point out that if you want to select all the worksheets in the
active workbook, you can use this single line of code to do that...

ActiveWorkbook.Worksheets.Select

--
Rick (MVP - Excel)


"AirgasRob" wrote in message
...
I know how to select all sheets but need to be able to filter which sheets
I
want selected. Can I select a sheet in a workbook based on criteria in a
specific cell?

This is the code I used to select all sheets.

Dim arySheets
Dim sh
Dim i As Long

ReDim arySheets(ActiveWorkbook.Worksheets.Count - 1)

For Each sh In ActiveWorkbook.Worksheets
arySheets(i) = sh.Name
i = i + 1
Next sh
Sheets(arySheets).Select



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
Move data to new sheet - rename sheet based on criteria ? [email protected] Excel Discussion (Misc queries) 7 May 16th 07 10:22 PM
Select criteria based on date N85DZ Excel Discussion (Misc queries) 2 May 10th 07 03:34 AM
Select rows based on criteria sotiris_s Excel Worksheet Functions 4 November 14th 05 12:35 PM
data validation list should have opt. to select based on criteria be Excel Worksheet Functions 1 September 15th 05 01:05 PM
Can I select a worksheet based upon a cell criteria?(for printing) Tim Richards Excel Worksheet Functions 0 March 30th 05 07:03 PM


All times are GMT +1. The time now is 06:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"