Check for worksheet name along column

sofas

Active Member
Joined
Sep 11, 2022
Messages
469
Office Version
  1. 2019
Platform
  1. Windows
Hello. I want help modifying the code to be able to execute a specific code when checking that the worksheet name is on any cell of column A provided there is no space in column b
I am now checking specific cells what is required is to check along columns A and B

VBA Code:
Sub test()
Dim wkSht As Worksheet
For Each wkSht In Sheets
      On Error Resume Next

 If Sheets("Sheet1").Range("b2").Value <> "" And Sheets("sheet1").Range("a2").Value = wkSht.Name Then
  MsgBox "Available"
 
 
        Else
     End If
    Next
Exit Sub
End Sub
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
You want to check all the sheets in the entire column A of sheet1.
If multiple sheets match, what is the result you need?
 
Upvote 0
You want to check all the sheets in the entire column A of sheet1.
If multiple sheets match, what is the result you need?
It doesn't matter, the important thing is that Tim discovers at least one name in column A corresponding to a value in column B. In this way, a message is shown stating that.
 
Upvote 0
It doesn't matter, the important thing is that Tim discovers at least one name in column A corresponding to a value in column B. In this way, a message is shown stating that.
I don't know how to interpret that...

I'm not sure if the following is what you need.

Try and tell me.
VBA Code:
Sub test_v2()
  Dim sh As Worksheet, sh1 As Worksheet
  Dim f As Range
  
  Set sh1 = Sheets("Sheet1")
  For Each sh In Sheets
    If sh.Name <> sh1.Name Then
      Set f = sh1.Range("A:A").Find(sh.Name, , xlValues, xlWhole, , , False)
      If Not f Is Nothing Then
        If sh1.Range("B" & f.Row).Value <> "" Then
          MsgBox "Sheets available " & sh.Name
          Exit For
        End If
      End If
    End If
  Next
End Sub

--------------
I hope to hear from you soon.
Respectfully
Dante Amor
--------------​
 
Upvote 1
Solution
I don't know how to interpret that...

I'm not sure if the following is what you need.

Try and tell me.
VBA Code:
Sub test_v2()
  Dim sh As Worksheet, sh1 As Worksheet
  Dim f As Range
 
  Set sh1 = Sheets("Sheet1")
  For Each sh In Sheets
    If sh.Name <> sh1.Name Then
      Set f = sh1.Range("A:A").Find(sh.Name, , xlValues, xlWhole, , , False)
      If Not f Is Nothing Then
        If sh1.Range("B" & f.Row).Value <> "" Then
          MsgBox "Sheets available " & sh.Name
          Exit For
        End If
      End If
    End If
  Next
End Sub

--------------
I hope to hear from you soon.
Respectfully
Dante Amor
--------------​
Really this is what is needed really thank you very much for the help
 
Upvote 0

Forum statistics

Threads
1,215,131
Messages
6,123,222
Members
449,091
Latest member
jeremy_bp001

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