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 can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Tetra201

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

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,286
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")??
 

Watch MrExcel Video

Forum statistics

Threads
1,130,335
Messages
5,641,560
Members
417,220
Latest member
lam150498

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