Forum Discussion
CZeus
Feb 17, 2023Copper Contributor
Need help with macro to autofill rows
Hello, I am trying to write a macro, and I am not used to VBA nor do I have much experience writing code to begin with, however I found some code from other posts that almost gets the job done that I...
HansVogelaar
Feb 17, 2023MVP
How about
Private Sub UpdateValues_Click()
Dim w As Worksheet
Dim m As Long
Set w = Worksheets("Data")
m = w.Range("H" & w.Rows.Count).End(xlUp).Row
If m = 1 Then Exit Sub
Application.ScreenUpdating = False
Application.ScreenUpdating = True
Range("L2:L" & m).Formula2 = "=D2"
Range("M2:M" & m).Formula2 = "=MONTH(B2) & ""/"" & DAY(B2) & ""/"" & YEAR(B2)"
Range("N2:N" & m).Formula2 = "=HOUR(B2) & "":"" & RIGHT(""0"" & MINUTE(B2),2)"
Range("O2:P" & m).Formula2 = "=TIMEVALUE(N2)"
Range("P2:P" & m).Formula2 = "=IF(AND(O2>=Q$1,O2<Q$2),""1"",IF(AND(O2>=Q$2,O2<Q$3),""2"",""3""))"
Range("R2:R" & m).Formula2 = "=IF(ISBLANK(H2),""Good"",TEXTSPLIT(H2,""|""))"
End SubCZeus
Feb 17, 2023Copper Contributor
that worked, and is a lot more concise than mine. Thank you for the help!