Darkcloud617
New Member
- Joined
- Sep 7, 2017
- Messages
- 38
Hello. This forum is absolutely wonderful and I have learned so much- so Thank You All. I have one last code to finish a spreadsheet I have been working on. I am attempting to write a code that checks column B (which contains dates) and if all dates in that column do not match then it should return a popup saying so. Essentially Column B should all be the same date and this will act as error catcher if they all are not the same (even if one cell is different). This is help a pivot table from adding in other dates and changing the structure.
For some reason it returns the popup everytime the macro is used, even if all the dates in column b are the same. I thought this code would essentially say 'if date is greater than or less than the date in B2 then use popup'. I am not quite sure what I am missing from this.
Thank you for any help you can provide.
Code:
With Worksheets("Sheet1")
For i = 2 To .Cells(.Rows.Count, "B").End(xlUp).Row
If .Cells(i, "B").Value <> "B2" Then
MsgBox "Please make sure only one date is in Column B."
Exit For
End If
Next i
End With
For some reason it returns the popup everytime the macro is used, even if all the dates in column b are the same. I thought this code would essentially say 'if date is greater than or less than the date in B2 then use popup'. I am not quite sure what I am missing from this.
Thank you for any help you can provide.