Forum Discussion
KristelNulens
Nov 14, 2024Copper Contributor
Need help with VBA code
The below piece of code, in the attached macro, is not returning the expected result. The column 'Reference Visit', in the 'All Visits' tab, remains empty.
Section of code:
' Check for specific values in the 'Visit' column and assign corresponding 'Reference Visit' values
Select Case visitValue
Case "Screening Day -28 to 1"
wsAllVisits.Cells(k, refVisitColAll).Value = "C1, Day 1"
Case "C1, Day 1"
wsAllVisits.Cells(k, refVisitColAll).Value = "Screening Day -28 to 1"
Case "C1, Day 8"
wsAllVisits.Cells(k, refVisitColAll).Value = "C1, Day 1"
' Add more cases if necessary
Case Else
wsAllVisits.Cells(k, refVisitColAll).Value = "" ' Leave blank or assign default if no match
End Select
Next k
2 Replies
Sort By
If cell.Value = "Visit Sequence" Then visitColAll = cell.Column
sets visitColAll to 4 (column D).
However, the values you are looking for in the Select Case ... End Select block are in column 5 (column E).
- KristelNulensCopper Contributor
Embarassing! 😠Thank you!