Macro to insert Concatenate formula with "-" between values (using R1C1) Not Working

jwb1012

Board Regular
Joined
Oct 17, 2016
Messages
167
Hello, any thoughts on why the below macro is resulting in a runtime error 13? I am trying to concatenate the values in column N and DO with a "-" in the middle. If I remove the "-" it works..... just not sure why I cant put a "-" between the two values. I also tried without "" and it doesn't work either.

Any thoughts?

Code:
Sub Concatenate()
    Dim CalcMode As Long
    Dim ViewMode As Long
    Dim LastColumn As Integer
    Dim LastRow As Integer
    
    With Application
        .ScreenUpdating = False
    End With
    'Select "Inventory Transaction Summary" worksheet, insert new column "Value less VAT", insert calculation (BMP*Q)
    With Sheets("Inventory Transaction Summary -")
        'Improves speed of macro
        .Select
        ViewMode = ActiveWindow.View
        ActiveWindow.View = xlNormalView
        .DisplayPageBreaks = False
        
    'Insert "Value less VAT" column heading after last column
    LastColumn = ActiveSheet.UsedRange.Columns.Count
    LastRow = ActiveSheet.UsedRange.Rows.Count
    ActiveSheet.Cells(1, LastColumn + 1) = "NSN Batch Number"
    
    Range(Cells(2, LastColumn + 1), Cells(LastRow, LastColumn + 1)).FormulaR1C1 = "=CONCATENATE(RC14," - ",RC119)"
    
    End With
    
    ActiveWindow.View = ViewMode
    With Application
        .ScreenUpdating = True
    End With
End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Sektor

Well-known Member
Joined
May 6, 2011
Messages
2,874
Office Version
  1. 365
Platform
  1. Windows
"=concatenate(rc14,"" - "",rc119)"
 

Tetra201

MrExcel MVP
Joined
Oct 14, 2016
Messages
3,747
It should be ....FormulaR1C1 = "=CONCATENATE(RC14,"" - "",RC119)"
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,344
Office Version
  1. 365
Platform
  1. Windows
Try this.
Code:
 Range(Cells(2, LastColumn + 1), Cells(LastRow, LastColumn + 1)).FormulaR1C1 = "=RC14 & "" - "" & RC119"
 

jwb1012

Board Regular
Joined
Oct 17, 2016
Messages
167
Is it possible to the convert the formulas to values? (i.e. something along the lines of ".value")??
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,836
Messages
5,833,904
Members
430,242
Latest member
Bancam

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
Top