Prev Previous Post   Next Post Next
  #1   Report Post  
nc
 
Posts: n/a
Default If then VBA

Hi

Can I simplify the codes below, is it possible to use
Select Case?

Thanks.

On Error Resume Next

Range("B1:B500").Find("Product ").Select
InvReqHeadingRowNo = ActiveCell.Row

If Range("A1") = "" And Err < 0 Then
Msg = "This invoice request is incorrectly
formatted."
Msg = Msg & vbCrLf & "The title and products must
be in cell A1 and column B respectively."
Msg = Msg & vbCrLf & "Please ammend the invoice
request before tranferring to template."
Msg = MsgBox(Msg, , "Formatting error")
Workbooks(InvReqWbkNme).Activate
Exit Sub
ElseIf Err < 0 Then
Msg = "This invoice request is incorrectly
formatted."
Msg = Msg & vbCrLf & "The products must be in
column B."
Msg = Msg & vbCrLf & "Please ammend the invoice
request before tranferring to template."
Msg = MsgBox(Msg, , "Formatting error")
Workbooks(InvReqWbkNme).Activate
Exit Sub
ElseIf Range("A1") = "" Then
Msg = "This invoice request is incorrectly
formatted."
Msg = Msg & vbCrLf & "The title must be in cell
A1"
Msg = Msg & vbCrLf & "Please ammend the invoice
request before tranferring to template."
Msg = MsgBox(Msg, , "Formatting error")
Workbooks(InvReqWbkNme).Activate
Exit Sub
End If
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"