Do Until Loop Looking to place the values from columns C, K, L, M, N, (only if t
ID: 3561327 • Letter: D
Question
Do Until Loop
Looking to place the values from columns C, K, L, M, N, (only if there is a value in the cell) & date to column B and expand down the rows until cell C# is blank.
e.g. if there is a value in column N, the value in column B would be "C - K - L - M - N - Date"
if there is no value in column N, then the value in column B would be "C - K - L - M - Date"
What is the best way to update the VBA below...or use another loop?
Dim r As Long
r = 2
Do Until Range("C" & r).Value = ""
Range("B" & r).Value = Range("C" & r).Text & " - " & _
Range("K" & r).Text & " - " & Range("L" & r).Text & " - " & _
Range("M" & r).Text & " - " & Range("N" & r).Text & " - " & Date
r = r + 1
Loop
Explanation / Answer
KJust use an IIF:"
Sub test()
Dim r As Long
r = 2
Do Until Range("C" & r).Value = ""
Range("B" & r).Value = Range("C" & r).Text & " - " & _
Range("K" & r).Text & " - " & Range("L" & r).Text & " - " & _
Range("M" & r).Text & IIf(Range("N" & r).Text <> "", " - " _
& Range("N" & r).Text, "") & " - " & Date
r = r + 1
Loop
End Sub
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.