Consulting

Results 1 to 2 of 2

Thread: Force data entry in cell b1 if data exists in cell a1

  1. #1

    Force data entry in cell b1 if data exists in cell a1

    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

    [VBA]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[/VBA]
    Last edited by Bob Phillips; 02-08-2012 at 08:14 AM. Reason: Added VBA tags

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Post your workbook, it is hard to envisage what you are doing.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •