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
Related
I am getting the following error
My code below
GrossMean = WorksheetFunction.Average("AK21:AK100020")
sheet1.Cells(4, 44) = GrossMean
Define the range and in which worksheet it is as:
GrossMean = WorksheetFunction.Average(ThisWorkbook.Worksheets("Sheet1").Range("AK21:AK100020"))
And make sure that there is numeric data in that range. If it is empty you get the same error.
I'm trying to find the location of a specific string in vba.
The following code gives me the error: Run-time error 91: Object Variable or with block variable not set.
With Range("A2:A62")
Position = .Find("Unplanned").Address
End With
So I tried setting the variable with the following code which gave me the error: compile error type mismatch
With Range("A2:A62")
Dim Position As Range
Set Position = .Find("Unplanned").Address
End With
So then I randomly tried this which gave me compile error:object required
With Range("A2:A62")
Set Position = .Find("Unplanned ").Address
End With
Is there a certain type I should be using or way of writing this that would work better? - I'm very new and self taught with VBA.
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.
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!
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