Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote