I have been looking around to find good examples, but can't find what I need.
Here is the context: The code is for a sales tracker worksheet with around 50 vendors (each of them can add value and most of them didn't know anything about Excel).
I want to select the first empty cell (where the first they can enter a value is B5, not higher, because the top of the sheet includes some instructions). In fact, from this cell (Date value is in Column B, and begin in Row 5) the second date value is in B6
Add the Date (date or now) as activecell.value
Then 2 cells to the right activecell.offset(0,2)
And insert the value of the textbox (their ID).
For now, I can add the date and the Textbox ID.
Here what I have so far:
Sub CommandButton1_click()
Dim Input_ID As String, Date_in As String
Date_in = Format(Now, "DD-MMM")
ActiveCell.Value = Date_in
Input_ID = InputBox("SVP entré votre ID ", "Data Entry Form")
ActiveCell.Offset(0, 2) = Input_ID
End Sub
But is it possible to make that command/button only available for column "B?" Because I don't what them add a date and their ID to another Column.
PS: I More or less begin in VBA, I learn from a bit of everywhere, So if you could add some explanation in your code, i appreciate it. Thanks
Edit1: Post from comment
Sub Date_insert_click()
Dim Input_ID As String, Date_in As String
Dim ws As Worksheet
Set ws = ActiveSheet 'change to your actual worksheet
'Dim Date_in As Date
Date_in = Format(Now, "DD-MMM")
With ws.Range("B" & ws.Rows.Count).End(xlUp)
If .Row >= 4 Then .Offset(1, 0).Value = Date_in Else Exit Sub
Input_ID = InputBox("SVP entré votre ID ", "Data Entry Form")
If Input_ID <> "" Then .Offset(1, 1).Value = Input_ID Else .Offset(1, 0).Value = ""
End With
End Sub
But I found a weakness. If I select a cell anywhere down like K378
,
I Still can add the value (date_In or value of the inputbox) but can't see it because the cell isn't active.