Hi All, I'm hoping someone can help me....
I have a few sheets that all look the same but there's a value in K2 on some of the sheets that I need to reference to sum up the values.
For example:
on my Summary sheet, C2 =
1) loop through all the sheets and find "Red" in K2
2) If Red is found in K2, sum the value in Summary!C2 for those sheets
I found the following and tried to do cut it up to use the values in a formula rather than a msgbox
When I added a formula with "rngFound" it returned with a ?NAME error
Any suggestions?
I have a few sheets that all look the same but there's a value in K2 on some of the sheets that I need to reference to sum up the values.
For example:
on my Summary sheet, C2 =
1) loop through all the sheets and find "Red" in K2
2) If Red is found in K2, sum the value in Summary!C2 for those sheets
I found the following and tried to do cut it up to use the values in a formula rather than a msgbox
VBA Code:
Dim ws As Worksheet
Dim strWhat As String
Dim rngSearch As Range
Dim rngFound As String
Dim i As Integer
strWhat = "Red"
For Each ws In Worksheets
Set rngSearch = ws.Cells.Find(What:=strWhat)
If Not rngSearch Is Nothing Then
i = i + 1
If i = 1 Then
rngFound = rngSearch.Worksheet.Name
Else
rngFound = rngFound & ", " & rngsearch.worksheet.name/']rngSearch.Worksheet.Name
End If
End If
Next ws
MsgBox "'" & strWhat & "' found on the following worksheet(s): " & rngFound & "."
When I added a formula with "rngFound" it returned with a ?NAME error
Any suggestions?