PDA

View Full Version : Force data entry in cell b1 if data exists in cell a1



shaps29
02-08-2012, 07:37 AM
Hello - I am trying to force a date entry in a cell if data exists in a previous cell. Basically for every row of detail thats entered I'm looking for the date field to be populated in the correct syntex, because without a date an upload of data will fail. If a user populated rows 1 & 2 the date column will need to be popluated, if row 3 is not populated no date is needed, etc. Someone posted this code which is excellent for forcing a date, but I only want to force it if data is present in the row. Thanks for your help

Private Sub Worksheet_Activate()
If (Not IsDate(Cells(1, 1).Value)) Then
Cells(1, 1).Value = InputBox("Enter a date in A1 cell", "No Date")
Worksheet_Activate
ElseIf (Not IsDate(Cells(1, 2).Value)) Then
Cells(1, 2).Value = InputBox("Enter a date in B1 cell", "No Date")
Worksheet_Activate
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Worksheet_Activate
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Worksheet_Activate
End Sub

Bob Phillips
02-08-2012, 08:14 AM
Post your workbook, it is hard to envisage what you are doing.