for findinh in how many sheets same value is found

jishnu

New Member
Joined
Mar 25, 2019
Messages
15
I am searching for a string in more than 1 worksheet (in a entire workbook with more than 10 sheets) . For this i am looping through all the worksheets to find the results. Is there any way for me to know , IN HOW MANY SHEETS THE VALUE HAS BEEN FOUND?? Precisely, i want to know whether a value is present in 2 sheets.

the code is given below.

Sub LoopThroughSheets(i)
Dim findRng As Range
Dim notFound As Boolean

notFound = True

Workbooks(SYSDatei).Activate


For j = 0 To SizeOfMKB_array - 1
For Each ws In Workbooks(SYSDatei).Worksheets
wsName = ws.Name

With Workbooks(SYSDatei).Worksheets(wsName)


Set findRng = .UsedRange.Find(MKB_array(j), lookat:=xlPart)


If Not findRng Is Nothing Then
firstRow = findRng.row
Column = findRng.Column
notFound = False
Set findRng = .UsedRange.Find(MKB_array(j), After:=Cells(firstRow, Column), lookat:=xlPart)
If Not findRng Is Nothing Then
CurrentRow = findRng.row
Call SearchForPKZ(CurrentRow, i)
End If

Do

Set findRng = .UsedRange.Find(MKB_array(j), After:=Cells(CurrentRow, Column), lookat:=xlPart)

If Not findRng Is Nothing Then
CurrentRow = findRng.row
Call SearchForPKZ(CurrentRow, i)
End If


Loop While CurrentRow <> firstRow ' here it goes for first row again at the end of the loop. so it better not to call searchforPKZ wt the first time when we find MKB

End If


End With


Next ws

Next j

If notFound Then
Workbooks(Plannungsdatei).Worksheets("DB").Cells(i, ColOfSYSTT_inPlannung).Interior.ColorIndex = 3 ' red
End If


End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,224,827
Messages
6,181,195
Members
453,021
Latest member
pingpong7117

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top