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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try this.
Code:
 Range(Cells(2, LastColumn + 1), Cells(LastRow, LastColumn + 1)).FormulaR1C1 = "=RC14 & "" - "" & RC119"
 
Upvote 0
Is it possible to the convert the formulas to values? (i.e. something along the lines of ".value")??
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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