Forum Discussion
hrh_dash
Aug 05, 2022Iron Contributor
Macro to concatenate for row 2 to the last row
I would like to create a simple dynamic concatenate macro to merge both strings in column B and C. However, it popping out an error "run time error 13 type mismatch". Below is my code so far: Sub ...
- Aug 05, 2022
Sub test() Dim ws As Worksheet Dim lastRow As Long Dim str1 As Variant Dim str2 As Variant Set ws = Tabelle1 lastRow = ws.Cells(ws.Rows.Count, "B").End(xlUp).EntireRow.Row str1 = ws.Range("B2:B" & lastRow).Value str2 = ws.Range("C2:C" & lastRow).Value ws.Range("I2:I" & lastRow).FormulaR1C1 = "=RC[-7]&"" ""& RC[-6]" End SubYou can try this code which seems to work in my sheet (sheetname is Tabelle1).
OliverScheurich
Aug 05, 2022Gold Contributor
Sub test()
Dim ws As Worksheet
Dim lastRow As Long
Dim str1 As Variant
Dim str2 As Variant
Set ws = Tabelle1
lastRow = ws.Cells(ws.Rows.Count, "B").End(xlUp).EntireRow.Row
str1 = ws.Range("B2:B" & lastRow).Value
str2 = ws.Range("C2:C" & lastRow).Value
ws.Range("I2:I" & lastRow).FormulaR1C1 = "=RC[-7]&"" ""& RC[-6]"
End SubYou can try this code which seems to work in my sheet (sheetname is Tabelle1).
- hrh_dashAug 06, 2022Iron Contributorthanks for the assistance!