A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

List specific worksheets



 
 
Thread Tools Display Modes
  #1  
Old May 30th, 2008, 01:49 PM posted to microsoft.public.excel.misc
Adrian Bear
external usenet poster
 
Posts: 6
Default List specific worksheets

I can produce a list of ALL worksheets in a workbook. How can I produce a
list limited to, say, a specific text string in a particular cell in each
worksheet?

--
Adrian
  #2  
Old May 30th, 2008, 02:06 PM posted to microsoft.public.excel.misc
Bernie Deitrick
external usenet poster
 
Posts: 2,496
Default List specific worksheets

Dim WS As Worksheet
For Each WS In ActiveWorkbook.Worksheets
If WS.Range("A1").Value Like "*Adrian* Then
'Add WS.Name to your list here
End If
Next WS

HTH,
Bernie
MS Excel MVP


"Adrian Bear" wrote in message
...
I can produce a list of ALL worksheets in a workbook. How can I produce a
list limited to, say, a specific text string in a particular cell in each
worksheet?

--
Adrian



  #3  
Old May 30th, 2008, 02:50 PM posted to microsoft.public.excel.misc
Adrian Bear
external usenet poster
 
Posts: 6
Default List specific worksheets

Dear Bernie,

Many thanks for the speedy response.

However, apologies for being dense, but I still have problems.

I'm using Excel 2003 (should have mentioned that at the start)

In a worksheet named "List Sheets" I have a command button which, when
clicked, should run the code you sent - putting the list on the same
worksheet starting from cell c2 (say) where I place the cursor

So, I have the following:

Private Sub CommandButton2_Click()
Dim WS As Worksheet
For Each WS In ActiveWorkbook.Worksheets
If WS.Range("B32").Value Like ("Y") Then
'Add WS.Name '
End If
Next WS

End Sub

Where am I going wrong?

Again thanks
--
Adrian


"Bernie Deitrick" wrote:

Dim WS As Worksheet
For Each WS In ActiveWorkbook.Worksheets
If WS.Range("A1").Value Like "*Adrian* Then
'Add WS.Name to your list here
End If
Next WS

HTH,
Bernie
MS Excel MVP


"Adrian Bear" wrote in message
...
I can produce a list of ALL worksheets in a workbook. How can I produce a
list limited to, say, a specific text string in a particular cell in each
worksheet?

--
Adrian




  #4  
Old May 30th, 2008, 04:41 PM posted to microsoft.public.excel.misc
Bernie Deitrick
external usenet poster
 
Posts: 2,496
Default List specific worksheets

Adrian,

You're not actually listing the sheets: that was code that I thought you had already developed.
Here is my take:

Private Sub CommandButton2_Click()
Dim WS As Worksheet
Dim i As Integer
Dim myR As Long
Dim myC As Integer

myR = ActiveCell.Row
myC = ActiveCell.Column

For Each WS In ActiveWorkbook.Worksheets
If WS.Range("B32").Value = "Y" Then
Worksheets("List Sheets").Cells(myR, myC).Value = WS.Name
myR = myR + 1
End If
Next WS

End Sub

HTH,
Bernie
MS Excel MVP


"Adrian Bear" wrote in message
news
Dear Bernie,

Many thanks for the speedy response.

However, apologies for being dense, but I still have problems.

I'm using Excel 2003 (should have mentioned that at the start)

In a worksheet named "List Sheets" I have a command button which, when
clicked, should run the code you sent - putting the list on the same
worksheet starting from cell c2 (say) where I place the cursor

So, I have the following:

Private Sub CommandButton2_Click()
Dim WS As Worksheet
For Each WS In ActiveWorkbook.Worksheets
If WS.Range("B32").Value Like ("Y") Then
'Add WS.Name '
End If
Next WS

End Sub

Where am I going wrong?

Again thanks
--
Adrian


"Bernie Deitrick" wrote:

Dim WS As Worksheet
For Each WS In ActiveWorkbook.Worksheets
If WS.Range("A1").Value Like "*Adrian* Then
'Add WS.Name to your list here
End If
Next WS

HTH,
Bernie
MS Excel MVP


"Adrian Bear" wrote in message
...
I can produce a list of ALL worksheets in a workbook. How can I produce a
list limited to, say, a specific text string in a particular cell in each
worksheet?

--
Adrian






  #5  
Old June 2nd, 2008, 09:28 AM posted to microsoft.public.excel.misc
Adrian Bear
external usenet poster
 
Posts: 6
Default List specific worksheets

Dear Bernie,

I'm grateful for all of your trouble. I tried your code and got:

run-time error '9'
subscript out of range

The debugger highlighted the line below "Then"

Sorry!
--
Adrian


"Bernie Deitrick" wrote:

Adrian,

You're not actually listing the sheets: that was code that I thought you had already developed.
Here is my take:

Private Sub CommandButton2_Click()
Dim WS As Worksheet
Dim i As Integer
Dim myR As Long
Dim myC As Integer

myR = ActiveCell.Row
myC = ActiveCell.Column

For Each WS In ActiveWorkbook.Worksheets
If WS.Range("B32").Value = "Y" Then
Worksheets("List Sheets").Cells(myR, myC).Value = WS.Name
myR = myR + 1
End If
Next WS

End Sub

HTH,
Bernie
MS Excel MVP


"Adrian Bear" wrote in message
news
Dear Bernie,

Many thanks for the speedy response.

However, apologies for being dense, but I still have problems.

I'm using Excel 2003 (should have mentioned that at the start)

In a worksheet named "List Sheets" I have a command button which, when
clicked, should run the code you sent - putting the list on the same
worksheet starting from cell c2 (say) where I place the cursor

So, I have the following:

Private Sub CommandButton2_Click()
Dim WS As Worksheet
For Each WS In ActiveWorkbook.Worksheets
If WS.Range("B32").Value Like ("Y") Then
'Add WS.Name '
End If
Next WS

End Sub

Where am I going wrong?

Again thanks
--
Adrian


"Bernie Deitrick" wrote:

Dim WS As Worksheet
For Each WS In ActiveWorkbook.Worksheets
If WS.Range("A1").Value Like "*Adrian* Then
'Add WS.Name to your list here
End If
Next WS

HTH,
Bernie
MS Excel MVP


"Adrian Bear" wrote in message
...
I can produce a list of ALL worksheets in a workbook. How can I produce a
list limited to, say, a specific text string in a particular cell in each
worksheet?

--
Adrian






  #6  
Old June 2nd, 2008, 09:54 AM posted to microsoft.public.excel.misc
Adrian Bear
external usenet poster
 
Posts: 6
Default List specific worksheets

Dear Bernie,

Ignore the last message - it works fine and I'm eternally grateful!

Many, Many thanks

Cheers

--
Adrian


"Adrian Bear" wrote:

Dear Bernie,

I'm grateful for all of your trouble. I tried your code and got:

run-time error '9'
subscript out of range

The debugger highlighted the line below "Then"

Sorry!
--
Adrian


"Bernie Deitrick" wrote:

Adrian,

You're not actually listing the sheets: that was code that I thought you had already developed.
Here is my take:

Private Sub CommandButton2_Click()
Dim WS As Worksheet
Dim i As Integer
Dim myR As Long
Dim myC As Integer

myR = ActiveCell.Row
myC = ActiveCell.Column

For Each WS In ActiveWorkbook.Worksheets
If WS.Range("B32").Value = "Y" Then
Worksheets("List Sheets").Cells(myR, myC).Value = WS.Name
myR = myR + 1
End If
Next WS

End Sub

HTH,
Bernie
MS Excel MVP


"Adrian Bear" wrote in message
news
Dear Bernie,

Many thanks for the speedy response.

However, apologies for being dense, but I still have problems.

I'm using Excel 2003 (should have mentioned that at the start)

In a worksheet named "List Sheets" I have a command button which, when
clicked, should run the code you sent - putting the list on the same
worksheet starting from cell c2 (say) where I place the cursor

So, I have the following:

Private Sub CommandButton2_Click()
Dim WS As Worksheet
For Each WS In ActiveWorkbook.Worksheets
If WS.Range("B32").Value Like ("Y") Then
'Add WS.Name '
End If
Next WS

End Sub

Where am I going wrong?

Again thanks
--
Adrian


"Bernie Deitrick" wrote:

Dim WS As Worksheet
For Each WS In ActiveWorkbook.Worksheets
If WS.Range("A1").Value Like "*Adrian* Then
'Add WS.Name to your list here
End If
Next WS

HTH,
Bernie
MS Excel MVP


"Adrian Bear" wrote in message
...
I can produce a list of ALL worksheets in a workbook. How can I produce a
list limited to, say, a specific text string in a particular cell in each
worksheet?

--
Adrian






 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:04 PM.


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