ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   trying to build in a check (https://www.excelbanter.com/excel-programming/428508-trying-build-check.html)

bernd

trying to build in a check
 
Hi

This code works fine, but I'm sure it can be done more easy! Can
somebody help me out?

Sub start()
If Worksheets("atm").Range("C4").Value < "Plan.r." Then
MsgBox " check again",true
Exit Sub
End If
If Worksheets("atm").Range("D4").Value < "Inv.rg." Then
MsgBox "check again", true
Exit Sub
End If
If Worksheets("atm").Range("H4").Value < "type" Then
MsgBox "check again", true
Exit Sub
End If
etc...
etc....

Call AE_1B2

End Sub

Thanks in advance.

Bernd

Dave Peterson

trying to build in a check
 
One way:

Option Explicit
Sub StartIt()

Dim myCell As Range

Set myCell = Worksheets("ATM").Range("C4")

Select Case LCase(myCell.Value)
Case Is = LCase("plan.r"), LCase("inv.rg."), LCase("type")
MsgBox "Check again"
Exit Sub
End Select

MsgBox "other stuff here"

End Sub


bernd wrote:

Hi

This code works fine, but I'm sure it can be done more easy! Can
somebody help me out?

Sub start()
If Worksheets("atm").Range("C4").Value < "Plan.r." Then
MsgBox " check again",true
Exit Sub
End If
If Worksheets("atm").Range("D4").Value < "Inv.rg." Then
MsgBox "check again", true
Exit Sub
End If
If Worksheets("atm").Range("H4").Value < "type" Then
MsgBox "check again", true
Exit Sub
End If
etc...
etc....

Call AE_1B2

End Sub

Thanks in advance.

Bernd


--

Dave Peterson


All times are GMT +1. The time now is 04:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com