What I have
- In Column B, I have the dates
- In Column I, I have engineers name
What I need
- I want a macro to generate Serial Nos. (1,2,3……. n) in column A If an only if the date in column B is today’s date and the engineer’s name matches with the PC’s username
The following is my code
Sub RequestID()
Dim x As Long
For x = 3 To Range("a" & Rows.Count).End(xlUp).row
If CDate(Range("b" & x).Text) = Date And UCase(Range("i" & x).Text) = UCase(UserName) Then ' checking for date and username
Dim myrange As Range
Dim rng As Range
Dim dblMax As Double
Set rng = Range("a1", Range("a65536").End(xlUp)) ' setting range
dblMax = Application.WorksheetFunction.Max(rng)
Range("a65536").End(xlUp).Offset(1, 0).Value = dblMax + 1
End If
Next
End Sub
and
Public Function UserName()
UserName = Environ$("UserName")
End Function
Problem:
- Above code runs without errors but does nothing
Bookmarks