Concatenate for VBA

beginvbaanalyst

Board Regular
Joined
Jan 28, 2020
Messages
139
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

I'm creating a concatenate for an unlimited range (1048558 rows) and thought I had this correct, but turns out it's not working for me.
VBA Code:
Sub ConcatenateArticleAssortment()
Dim AssortmentRows As Long
Dim ArticleRows As Long
AssortmentRows = Range("B" & Rows.Count).End(xlUp).Row
ArticleRows = Range("A" & Rows.Count).End(xlUp).Row
Range(ArticleRows & AssortmentRows).FormulaR1C1 = "=CONCATENATE(RC[-2],""-"",RC[-1])"
End Sub

The long that fails is Range(ArticleRows & AssortmentRows).FormulaR1C1 = "=CONCATENATE(RC[-2],""-"",RC[-1])"
I get an error of
1582908002306.png

What does this mean? Am I unable to do a concatenate like this?
Thank you for all the help this community has been giving me, you guys are amazing!
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
What are you trying to do?
 
Upvote 0
What are you trying to do?
Take ranges column A and B to create a concatenate until the last filled cell in each column.
I don't understand the error.

The concatenate will help with a manual validation step.
 
Upvote 0
Ok, how about
VBA Code:
Sub beginvba()
   Range("C2:C" & Range("A" & Rows.Count).End(xlUp).Row).FormulaR1C1 = "=rc[-2]&""-""&rc[-1]"
End Sub
 
Upvote 0
Ok, how about
VBA Code:
Sub beginvba()
   Range("C2:C" & Range("A" & Rows.Count).End(xlUp).Row).FormulaR1C1 = "=rc[-2]&""-""&rc[-1]"
End Sub

I realized I didn't give the formula a destination.
How does it know to take Column B when there's not a letter B in the Code?
Throwing me off a little.
Thank you for helping
 
Upvote 0
The rc[-1] is basically saying this row & 1 column to the left

Thank you for the explanation, I know exactly what I did that messed this up.
Have a great weekend Fluff!
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,872
Messages
6,122,025
Members
449,060
Latest member
LinusJE

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