I am an Excel rookie but only know the basics. I was able to find two VBA codes that will pretty much do what I am looking for. I am making a simple sheet that will keep track of all my incoming shipments. In column A I will have the date and time and in B will be the tracking number. The first code that I am using is that when the tracking number is bar coded into B2 then A2 will automatically populate the date and time and will remain the same the next day.
Code for the date:
The code that I tried out on a separate spreadsheet that is working is to lock the cells (A2:A37 where the date and time go) is:
What I want to know is how do I put both of these codes together on one sheet? Thank you in advance for any information.
Code for the date:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 2 Then Exit Sub
If Target.Row < 2 Then Exit Sub
If Target.Column > 2 Then Exit Sub
Cells(Target.Row, 1) = Now
End Sub
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
' Set Target Range, i.e. Range("A2:A37")
Set rng = Target.Parent.Range("A2:A37")
' Only look at single cell changes
If Target.Count > 1 Then Exit Sub
' Only look at that range
If Intersect(Target, rng) Is Nothing Then Exit Sub
' Action if Condition(s) are met
' Do your thing here
ActiveSheet.Unprotect "password"
Target.Locked = True
ActiveSheet.Protect "password"
End Sub