sycodiz
New Member
- Joined
- Jun 15, 2008
- Messages
- 27
I have an excel sheet that has a lot of different cells that I need to do a validation on.
I would like the pop ups to continue to pop up if there are issues with the cells based on the validations I created.
I originally created this macro with one If statement and the rest were all ElseIf until the end where I just used Else.
It worked, but as soon as it found an issue, the msgbox would display that issue and then close. I need it to continue to go through the rest of the code and pop up each time.
Here is a shortened version of the code of how I think I need to create this. I was wondering if anyone had any suggestions on how to shorten this code up?
Sub NewItemFormReview()
'
' NewItemFormReview Macro
'
Worksheets("New Item - View All").Select
If Range("C5").Value <> "New Item or Expand" Then
ElseIf Range("I13").Value < 1000 Or Range("I13") > 10001 Then MsgBox "MIP - CM ID: Cell I13 must be 4 digits"
End If
If Range("C5").Value <> "New Item or Expand" Then
ElseIf Application.WorksheetFunction.IsText(Range("c14")) = False Then MsgBox "Category Manager: Cell C14 must contain a name"
End If
If Range("C5").Value <> "New Item or Expand" Then
ElseIf IsEmpty(Range("e14").Value) = True Then MsgBox "Phone number E14 is empty"
End If
If Range("C5").Value <> "New Item or Expand" Then
ElseIf Application.WorksheetFunction.IsText(Range("G14")) = False Then MsgBox "Category Support Specialist: Cell G14 must contain a name"
End If
If Range("C5").Value <> "New Item or Expand" Then
ElseIf IsEmpty(Range("I14").Value) = True Then MsgBox "Phone number I14 is empty"
End If
End Sub
I would like the pop ups to continue to pop up if there are issues with the cells based on the validations I created.
I originally created this macro with one If statement and the rest were all ElseIf until the end where I just used Else.
It worked, but as soon as it found an issue, the msgbox would display that issue and then close. I need it to continue to go through the rest of the code and pop up each time.
Here is a shortened version of the code of how I think I need to create this. I was wondering if anyone had any suggestions on how to shorten this code up?
Sub NewItemFormReview()
'
' NewItemFormReview Macro
'
Worksheets("New Item - View All").Select
If Range("C5").Value <> "New Item or Expand" Then
ElseIf Range("I13").Value < 1000 Or Range("I13") > 10001 Then MsgBox "MIP - CM ID: Cell I13 must be 4 digits"
End If
If Range("C5").Value <> "New Item or Expand" Then
ElseIf Application.WorksheetFunction.IsText(Range("c14")) = False Then MsgBox "Category Manager: Cell C14 must contain a name"
End If
If Range("C5").Value <> "New Item or Expand" Then
ElseIf IsEmpty(Range("e14").Value) = True Then MsgBox "Phone number E14 is empty"
End If
If Range("C5").Value <> "New Item or Expand" Then
ElseIf Application.WorksheetFunction.IsText(Range("G14")) = False Then MsgBox "Category Support Specialist: Cell G14 must contain a name"
End If
If Range("C5").Value <> "New Item or Expand" Then
ElseIf IsEmpty(Range("I14").Value) = True Then MsgBox "Phone number I14 is empty"
End If
End Sub