Problem with VBA formula

DizzyBear

New Member
Joined
Jul 17, 2018
Messages
7
Hi! I am encountering a Compile error: Syntax error[FONT=&quot] [/FONT]with the VBA coding.

I would like to refer to column "Q" and produce the result of "CMS/DMS/SMS" in column "AX".

Do anyone know how can I fill up the formula to the last row?

The formula is

=IF(SUMPRODUCT(--ISNUMBER(SEARCH({"CDS","CNM","CMF","CSV"},Q2)))>0,"CMS",IF(SUMPRODUCT(--ISNUMBER(SEARCH({"SPM","SSV","SNM","SMF"},Q2)))>0,"SMS",IF(SUMPRODUCT(--ISNUMBER(SEARCH({"DPM","DSV","DNM","DMF"},Q2)))>0,"DMS",IF(SUMPRODUCT(--ISNUMBER(SEARCH({"KCD"},Q2)))>0,"CMS","SMS"))))





Below is the hardcoding I managed to come up with.



Sub Classification()
'
' Classification Macro
' SMS, DMS, CMS
'
' Keyboard Shortcut: Ctrl+Shift+M
'


Dim sht As Worksheet
Dim lastrow As Long
Set sht = ThisWorkbook.Worksheets("Sheet1")
lastrow = sht.Cells(sht.Rows.Count, "Q").End(xlUp).Row


Columns("AW:AW").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("AX1").Select
ActiveCell.FormulaR1C1 = "Macro"

Range("AX2:AX" & lastrow).Formula = "=IF(SUMPRODUCT(--ISNUMBER(SEARCH({"CDS","CNM","CMF","CSV"},Q2)))>0,"CMS",IF(SUMPRODUCT(--ISNUMBER(SEARCH({"SPM","SSV","SNM","SMF"},Q2)))>0,"SMS",IF(SUMPRODUCT(--ISNUMBER(SEARCH({"DPM","DSV","DNM","DMF"},Q2)))>0,"DMS",IF(SUMPRODUCT(--ISNUMBER(SEARCH({"KCD"},Q2)))>0,"CMS","SMS"))))"


End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,224,828
Messages
6,181,214
Members
453,024
Latest member
Wingit77

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