View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
crazybass2 crazybass2 is offline
external usenet poster
 
Posts: 167
Default Find ALL WorkSheets according to 2 ComboBox Values.... Help wi

Jim,

The code Corey has already outputs a list of all the sheets containing a
match for CB3 & CB4. He's got it commented out in the code he posted. I
think what he is looking for is to have the actual Excel FIND ALL dialog come
up with the appropriate sheets.

"Jim Thomlinson" wrote:

Here is some code. It creates a collection of all of the sheets that meet
both criteria...

Public Sub ReturnSheets()
Dim colSheets As Collection
Dim str1 As String
Dim str2 As String
Dim wks As Worksheet

str1 = "this"
str2 = "that"
Set colSheets = New Collection
For Each wks In Worksheets
If ContainsString(str1, wks) And ContainsString(str2, wks) Then
colSheets.Add wks, wks.Name
End If
Next wks

If colSheets.Count = 0 Then
Set colSheets = Nothing
MsgBox "Sorry..."
Else
For Each wks In colSheets
MsgBox wks.Name
Next wks
End If
End Sub

Public Function ContainsString(ByVal InputText As String, wks As Worksheet)
As Boolean
Dim rng As Range

Set rng = wks.Cells.Find(What:=InputText, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
MatchCase:=False)
If rng Is Nothing Then
ContainsString = False
Else
ContainsString = True
End If
End Function
--
HTH...

Jim Thomlinson


"Corey" wrote:

In my quest to perform a coded FIND i have reached the following code/s.

The first code is for the FIND.
The second is the Cell Values from 2 ComboBoxes.


__________________________________________________ ___________

Private Sub userform3OK_Click()
' FIND Code

Cells.Find(What:=ComboBox4&ComboBox3, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False).Activate

End Sub

__________________________________________________ ________________


Private Sub Userform_Activate()
' ComboBoxes and Userform Code
Dim wks As Worksheet
For Each wks In Worksheets
ComboBox3.AddItem wks.Range("B3").Text
Next wks
For Each wks In Worksheets
ComboBox4.AddItem wks.Range("D3").Text
Next wks

End Sub

__________________________________________________ _________________

I can yet get the FIND Code to Display (Somehow) ALL Sheets that Contain
both the ComboBox3 & ComboBox4 Values in a Single WorkSheet.
Like in a Manual (CTR+F) Find All Sheets FIND.

Any idea's.

Corey....