Converting IF statement to VBA with Variables - excel

I am trying to convert the following IF statement into text that will be filled into a cell through VBA:
=IF(XLOOKUP(N7,'EDL Filter'!R2:R660,'EDL Filter'!AA2:AA660)="YES","Port Specific",XLOOKUP(N7,'EDL Filter'!R2:R660,'EDL Filter'!AB2:AB660) )
I've tried splitting it up as I have with other Xlookup statements below:
ActiveCell = "=IF(XLookUp(N" & SafetyRow2 & ",'EDL Filter'!R2:R660,'EDL Filter'!AA2:AA660)=""Yes"",""Port Specific"", Xlookup(N" & SafetyRow2 & ",'EDL Filter'!AB2:AB660))"
However, I keep getting Run-time Error '1004': Application-defined or object-defined error.
The variables have been defined and used earlier in my code without issue, but I am still new to VBA so I might be missing something obvious.

Related

Why does using [#Name] in Excel VBA string cause error 1004?

When I try to execute this statement using Excel VBA, it gives an error 1004:
Cells(C, 2).Value = "=IFERROR(XLOOKUP([#Name],Master_List_1[Name],Master_List_1[Email]),""error"")"
If I remove the brackets around #Name, it works fine. The other brackets in the string don't cause trouble. Somehow VBA is parsing the text string and objecting to having [#Name] in there.
If I put the statement in a cell by hand (with single quotes), it works as it should. (I did forget the = sign; that's been corrected.

Excel VBA FormatConditions drops invalid procedure call or argument on the client

We have an excel, which contains some VBA code. For a table we write some VBA code to set up some preparation like these:
Worksheets("Activity Features").range("ActivityFeaturesTable[ProtonProject]").Formula = "=VLOOKUP([Proton],Table_PT2_Projects,2,FALSE)"
Worksheets("Activity Features").range("ActivityFeaturesTable[SUM]").Formula = "=SUM(ActivityFeaturesTable[#[C0001]:[C0500]])*#IF([#Multiplier]="""",1,[Multiplier])"
With Worksheets("Activity Features").range("ActivityFeaturesTable[StartDate]")
.FormatConditions.Add Type:=xlExpression, Formula1:="=IF(INDIRECT(""RC[-1]"",0) = ""From StartDate to EndDate"", FALSE, TRUE)"
End With
This *.FormatConditions.Add Type:=xlExpression .. * line drops Invalid procedure call or argument error, however lines before this executes without any error.
The error occurs only on one client laptop, we cannot reproduce, several other users never experienced this error before. We checked the client computer settings, the Regional settings "List separator" was set to ";" instead of "," - but changing back to "," does not helped at all. And VBA code lines before this one also contains "," as separator in the formula.
We wonder why this error happens on the client side on this line?! Any idea? Is there any problem with the INDIRECT or RC in the formula?
Thanks in advance!

Converting xlA1 Formula to xlR1C1 gives error

All of my formulas are converting without any issues it's just these following two formulas are giving me an error when I try to convert them to R1C1. Can someone please advise why is this happening ?
"=IF(Control!$B$116=1,"",IF(A24="","",IF('Sub Lot Input'!$L$25="","",IF(OR('Calcs - Conversion'!DJ9="",'Calcs - Conversion'!DJ9="-"),"-",IF(OR(Other_Analysis_Input_Field=4,Other_Analysis_Input_Field=5),MROUND('Calcs - Conversion'!DJ9,'Calcs - Conversion'!$AC$66),'Calcs - Conversion'!DJ9)))))"
"=IF(OR('Control'!$B$235=TRUE,'Control'!$B$236=TRUE),IF('Additional Analysis Input'!$C$14="","Degree C.",'Additional Analysis Input'!$C$14),"")"
I am converting the formula to R1C1 using the following line of code:
Formula = Application.ConvertFormula( _
Formula:=wk_sht.Range(cell).Formula, _
fromReferenceStyle:=xlA1, _
toReferenceStyle:=xlR1C1)
I am getting type mismatch error.

VBA - Error 1004 While delete range of column

I am trying to delete Column A,B,D,E,F,W,X,Y,Z,AA,AB of the sheet FeuilleFP21.
In order to do this I use as seen here and here:
FeuilleFP21.Range("A:B,D:F,W:AB").Delete
But it gives me the following error :
Execution error '1004': The 'Range' method of the '_Worksheet' object
failed.
NOTE : FeuilleFP21 is set like that and in Execution window return the name of the sheet when I use ? ?FeuilleFP21.Name
Set FeuilleFP21 = ClasseurFp21.Worksheets(1)
What am I doing wrong ?
System settings may cause the error. Try separating the columns with ; or whatevery you may have as a "List separator" on your system.

VBA Application Defined or Object-Defined Error with Formula

I'm trying to use the following formula, but am getting the error application defined or object defined error. I have a feeling it's due to the line break, but it looks good to me.
ActiveCell.FormulaR1C1 = _
"=IF(AND(R[1]C[-13]=RC[-13],R[1]C[-15]=RC[-15]),IF(AND(R[1]C[-8]=RC[-8],R[1]C[-3]<>RC[-3]),IF(AND(R[2]C[-8]=R[1]C[-8],R[2]C[-3]<>R[1]C[-3]),IF(AND(R[3]C[-8]=R[2]C[-8],R[3]C[-3]<>R[2]C[-3]),IF(AND(R[4]C[-13]=R[3]C[-13],R[4]C[-15]=R[3]C[-15]),"""",RC[-3]),IF(AND(R[3]C[-13]=R[2]C[-13],R[3]C[-15]=R[2]C[-15]),"""",RC[-3]))," & _
"IF(AND(R[2]C[-13]=R[1]C[-13],R[2]C[-15]=R[1]C[-15],"""",RC[-3])),""""),IF(RC[-3]="""","""",RC[-3]))"

Resources