Macro wont run formula

Jibroni

New Member
Joined
Apr 7, 2022
Messages
25
Office Version
  1. 365
  2. 2021
  3. 2019
Platform
  1. Windows
Hello,

Here is my code:

Sub Wordpress_CSV_Insert_Formula()

Dim lastRow As Long
lastRow = Range("A" & Rows.Count).End(xlUp).Row

Range("C2").Formula = "=CONCAT(B2, " (", A2, ")" )"
Range("C2").AutoFill Destination:=Range("C2:C" & lastRow)

End Sub

I get an error on the formula line.

Here is my spreadsheet:

Class IDCourse TitleCalendar Event Name
06052022_GST_301301 Administration Fundamentals301 Administration Fundamentals (06052022_GST_301)
08102022_CET_401401 Custom MPE Rules Using Regular Expression
08122022_CET_402402 Threat Detection with AI Engine

I applied the same formula directly to the C2 cell and it correctly returned the formula result. But the macro simply won't run. What am I doing wrong?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Easier ??
VBA Code:
Sub Wordpress_CSV_Insert_Formula()
Range("C2:C" & Range("A" & Rows.Count).End(xlUp).Row).Formula = "=CONCAT(B2,"" "",A2)"
End Sub
 
Upvote 0
Hi, my apologies, I should have specified that the formula needs to return a value that looks like this: 301 Administration Fundamentals (06052022_GST_301)
which is the value in B2 with the value in A2 in "( )".
 
Upvote 0
VBA Code:
Sub Wordpress_CSV_Insert_Formula()
Range("C2:C" & Range("A" & Rows.Count).End(xlUp).Row).Formula = "=B2&"" ""&""(""&A2&"")"""
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,236
Messages
6,170,915
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