VBA - Error 1004 While delete range of column - excel

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.

Related

Converting IF statement to VBA with Variables

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.

Defined Column name NOT working in simple Macro to Hide Column

I named a column: DailyReserveCol
Created simple Hide/Reveal column button
Sheets("Calculator").Columns.DailyReserveCol.Hidden = Not Column.DailyReserveCol.Hidden
But I receive the following error:
Run-time Error 424 Object Required
This works:
Sheets("Calculator").Columns("C").Hidden = Not Columns("C").Hidden
I've tried:
Columns(DailyReserveCol).Hidden
Columns("DailyReserveCol").Hidden
Error 13 Type mismatch
Am I doing it incorrectly or is this not possible?
You can use the following to toggle the visibility of a named column:
Sheets("Calculator").Range("DailyReserveCol").EntireColumn.Hidden = _
Not Sheets("Calculator").Range("DailyReserveCol").EntireColumn.Hidden

VBA: Application.WorksheetFunction.Max Runtime Error 1004

I can't seem to figure out what is wrong with my code. I am trying to set the maximum of a row to a variable lMax. This variable is declared earlier by "Dim lMax".
I try running the code and get the error: "Run=time error '1004': Method 'Cells' of object '_Global' failed. The code that fails is as follows:
lMax = Application.WorksheetFunction.Max( _
Worksheets("Data").Range(Cells(Selected_Row, 7), Cells(Selected_Row, 14).End(xlToRight))) 'Max value
The variable Selected_Row is the row the active row that the user was last on. It is a Global Long variable and was declared in the beginning of the module.
Please help! Thank you!

application.transpose error on startup

The code below has worked until my most recent update to it in. It still does work, but for some reason, it errors when opening it on a new PC if you have to click Enabling Editing. If you Enable Editing, end the routine, and close the spreadsheet, it works from there. I am just trying to understand what might be causing the hiccup on the initial open after Enabling Editing.
The code (please note that "Mnger_Tags" is a named group defined in the spreadsheet):
Dim Mnger As Variant, MngerCheck As String
Application.DisplayAlerts = False
'Determine User/Manager
Mnger = Application.Transpose(Range("Mnger_Tags").Value)
MngerCheck = LCase(Environ("UserName"))
If IsInArray(MngerCheck, Mnger) Then
frmMngerCheck.Show
MngerCheck = frmMngerCheck.MngerCheck
Unload frmMngerCheck
End If
The Error:
Takes place on line "Mnger = Application.Transpose(Range("Mnger_Tags").Value)"
Run-time error '1004':
Method 'Range' of object '_Global' failed
The goal:
The first line of code is meant to take whatever names are listed in that named range (Mnger_Tags) and create the array Mnger.
The code will then check if any value in the array Mnger match the UserName (MngerCheck).
I hope this is clear enough. This is my first post. Thank you all in advance.

How to iterate through multiples charts

I need to iterate and modify properties of some charts one by one, but for that I use ActiveChart ex.:
Target_str = ActiveChart.SeriesCollection(2).DataLabels.Item(1).Caption
Target = CDbl(Target_str)
To make my charts active I try to select them one by one:
For i = 1 To ActiveWorkbook.Sheets(2).ChartObjects.Count
ActiveWorkbook.Sheets(2).ChartObjects(i).Chart.Select
'...
Next i
But I get the following message in debug:
Run-time error '1004':
Unable to get the Select property of the Chart class
How can I make those charts active one by one, what am I doing wrong in the above code.
Can I use other alternative?
What about this?
ActiveWorkbook.Sheets(2).ChartObjects(i).Select

Resources