Dim ws As Worksheet Dim adminRequestCell As Range Set ws = Worksheets(Range(“I2”).Value)…
- User
Dim ws As Worksheet Dim adminRequestCell As Range Set ws = Worksheets(Range(“I2”).Value) Set adminRequestCell = ws.Range(“B:B”).Find(“Admin Request”, , xlValues, xlWhole, xlByColumns)
If Not isAdminRequestPresent = False Then GoTo CHECKS … I am using this vba code to check if the value “Admin Request” exists in column B of the Worksheet named in cell I2. If the value does not exist, I want to GoTo CHECKS, if the value does exit then I want to GoTo COMPLETE. How do I complete the above code
- Assistant
to achieve this?
Here's the updated code with the complete solution:
Dim ws As Worksheet Dim adminRequestCell As Range Set ws = Worksheets(Range("I2").Value) Set adminRequestCell = ws.Range("B:B").Find("Admin Request", , xlValues, xlWhole, xlByColumns)
If Not adminRequestCell Is Nothing Then 'if the value exists GoTo COMPLETE Else 'if the value doesn't exist GoTo CHECKS End If
COMPLETE: 'your code to execute when Admin Request is present
CHECKS: 'your code to execute when Admin Request is not present