mjkutzman
mjkutzman

Reputation: 27

VBA - Inserting a space between concatenated cells

This code works for me. However, in the destination cell, I'd like a space between A2 and B2's values:

For j = 1 To lastRow3
    If ws.Range("A" & j) = "OKUMA LATHE" Then
        Cells(j, lastCol2 + 2).Formula = "=$A2&$B2"
    End If
Next j

What's a boy to do? Everything I try gives me a compile error...

Upvotes: 2

Views: 1046

Answers (1)

SJR
SJR

Reputation: 23081

You need to double up the quotes in VBA

For j = 1 To lastRow3
    If ws.Range("A" & j) = "OKUMA LATHE" Then
        Cells(j, lastCol2 + 2).Formula ="=$A2 & "" "" & $B2"
    End If
Next j

Upvotes: 4

Related Questions