Hi,
I have data that the user imports to the data sheet, I have a text box where they enter the appropriate date. I would like this date to populate column A next to the imported data. With each import the date should be different. Not overwrite the previous dates in column A.
I just cannot get the text box to copy to the correct range without overwriting the previous dates. I am not very good with VBA but I am learning. If you are able to help can you explain how I set the correct range.
Thanks in advance
I have data that the user imports to the data sheet, I have a text box where they enter the appropriate date. I would like this date to populate column A next to the imported data. With each import the date should be different. Not overwrite the previous dates in column A.
I just cannot get the text box to copy to the correct range without overwriting the previous dates. I am not very good with VBA but I am learning. If you are able to help can you explain how I set the correct range.
Thanks in advance
Code:
Sub InputDate()
Dim strDate As String
Dim answer As Integer
strDate = InputBox("Insert date in format dd/mm/yy", "User date", Format(Now(), "dd/mm/yy"))
answer = MsgBox("Is the Date Correct? " & strDate, vbYesNo + vbQuestion, "Correct Date")
If answer = vbNo Then
strDate = InputBox("Insert date in format dd/mm/yy", "User date", Format(Now(), "dd/mm/yy"))
Else
Sheets("Data").Select
Sheets("Data").Select
Set rng = Range("B1:B10000")
For Each cell In rng
'test if cell is empty
If cell.Value <> "" Then
'write to adjacent cell
cell.Offset(1, -1).Value = strDate
End If
Next
End If
End Sub