1

So my code starts on a different sheet with a button click. The code below stops the user from continuing with an error message if the user does not put in a value in cell "B38" on the "Pricing checklist" sheet. Is there a way to bring the user to the cell so they can input a value?

If ThisWorkbook.Sheets("Pricing checklist").Range("B38").Value = "" Then
    MsgBox "Please enter the Sales Rep. " _
        & vbCrLf & vbCrLf & "Press OK to exit and try again.", vbCritical
    Exit Sub
End If
Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73

1 Answers1

0

Select a Cell Using Application.Goto

Sub CheckPrice()
    
    Dim PriceCell As Range
    Set PriceCell = ThisWorkbook.Worksheets("Pricing checklist").Range("B38")
    
    If Len(CStr(PriceCell.Value)) = 0 Then
        MsgBox "Please enter the Sales Rep. " _
            & vbCrLf & vbCrLf & "Press OK to exit and try again.", vbCritical
        Application.Goto PriceCell, True ' to not scroll, remove 'True'
        Exit Sub
    End If

End Sub
VBasic2008
  • 44,888
  • 5
  • 17
  • 28