ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Compile Error - Wrong number of arguements or invalid property ass (https://www.excelbanter.com/excel-programming/345923-compile-error-wrong-number-arguements-invalid-property-ass.html)

James T

Compile Error - Wrong number of arguements or invalid property ass
 
Created a very basic macro.

Spreadsheet has certain columns hidden and certain ones showing.

I just want the macro to hide all the columns I define (even if they are
already hidden or not)

However when I run it I get an error:

Compile Error - Wrong number of arguements or invalid property assignment.

It highlights the word "COLUMNS" in the debug.


Sub AmendReport()
'This macro unhides all columns and reopens the form for changes
Sheets("Report").Select
Columns("B:AW").Select
Selection.EntireColumn.Hidden = True
End Sub


Any thoughts?

NickHK

Compile Error - Wrong number of arguements or invalid property ass
 
James,
I assume this routine is not on the worksheet that you wish to change, but
in a module.
As such, "Columns" cannot be resolved. You would need a "Sheets("Report")."
in front.
Also, unless have a reason, there is no need to "Select". You can achieve
the same with:
Sheets("Report").Columns("B:AW").Hidden = True

NickHK

"James T" wrote in message
...
Created a very basic macro.

Spreadsheet has certain columns hidden and certain ones showing.

I just want the macro to hide all the columns I define (even if they are
already hidden or not)

However when I run it I get an error:

Compile Error - Wrong number of arguements or invalid property assignment.

It highlights the word "COLUMNS" in the debug.


Sub AmendReport()
'This macro unhides all columns and reopens the form for changes
Sheets("Report").Select
Columns("B:AW").Select
Selection.EntireColumn.Hidden = True
End Sub


Any thoughts?




Patrick Molloy[_2_]

Compile Error - Wrong number of arguements or invalid property ass
 
Sub AmendReport()

Sheets("Report").Range("B:AW").EntireColumn.Hidden = True

End Sub

"James T" wrote:

Created a very basic macro.

Spreadsheet has certain columns hidden and certain ones showing.

I just want the macro to hide all the columns I define (even if they are
already hidden or not)

However when I run it I get an error:

Compile Error - Wrong number of arguements or invalid property assignment.

It highlights the word "COLUMNS" in the debug.


Sub AmendReport()
'This macro unhides all columns and reopens the form for changes
Sheets("Report").Select
Columns("B:AW").Select
Selection.EntireColumn.Hidden = True
End Sub


Any thoughts?



All times are GMT +1. The time now is 04:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com