using concatenate in a macro to combine 2 cells with an ampersand between

alabing

New Member
Joined
Jul 25, 2012
Messages
3
column A contains the husband's name
column C contains the wife's name

If they both have the same last name (columns C and D) then column F contains "same last name"

So if they have the same last name, I want to combine the husband's and wife's first names with an ampersand between them and have that be in column E

I tired this:
Lastrow = Range("A65536").End(xlUp).Row
For x = Lastrow To 1 Step -1
If Range("f" & x).Value = "same last name" Then
Range("e" & x).Select
ActiveCell.Formula = _
"=concatenate("a" & x &" & " & "c" & x)"
End If
Next x
I get an "expected end of statement" compile error with the "a" flagged red.

So I tried this:
Lastrow = Range("A65536").End(xlUp).Row
For x = Lastrow To 1 Step -1
If Range("f" & x).Value = "same last name" Then
Range("e" & x).Select
ActiveCell.Formula = _
"=concatenate(a & x &" & " & c & x)"
End If
Next x
No error but when the macro ran, column e was blank

I tired:
Lastrow = Range("A65536").End(xlUp).Row
For x = Lastrow To 1 Step -1
If Range("f" & x).Value = "same last name" Then
Range("e" & x).Select
ActiveCell.Formula = _
"=concatenate(a & x, c & x)"
End If
Next x
No error but I got "0's" in column E.

Thanks,

Bill Roberts
Cumming, GA
Excel 97 ( i think )
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
This would work:

If LCase(Range("f" & x).Value) = "same last name" Then
Range("E" & x) = Range("A" & x).Value & " & " & Range("C" & x).Value
End If
 
Upvote 0

Forum statistics

Threads
1,216,030
Messages
6,128,407
Members
449,448
Latest member
Andrew Slatter

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top