ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Compile error in Excel (https://www.excelbanter.com/excel-programming/365961-compile-error-excel.html)

MBA2004

Compile error in Excel
 

I have some macros that were working fine. Now, i'm getting a Compile
Error that says, "WRONG NUMBER OF ARGUMENTS OR INVALID PROPERTY
ASSIGNMENT."

It is having a problem with the following code:

Columns("H:I").Select
Selection.Delete Shift:=xlToLeft

This works in my other spreadsheets, but not in this one.

Any thoughts? I don't understand what the Compile Error is.

Thanks,
M


--
MBA2004
------------------------------------------------------------------------
MBA2004's Profile: http://www.excelforum.com/member.php...o&userid=35946
View this thread: http://www.excelforum.com/showthread...hreadid=557353


Casey[_113_]

Compile error in Excel
 

Your code works fine for me as written. Two observations.
Is the reason you are saying these lines of code are the source of the
error, is because they are highlighted when you select debug?
Second; it is rarely if ever necessary to select things in order to
work with them in VBA.
Your code:
Columns("H:I").Select
Selection.Delete Shift:=xlToLeft
Can be reduced to:
Columns("H:I").Delete Shift:=xlToLeft
and work better.

I might suggest that you post your entire code so the experts here can
help you. I'm not one of those experts by the way, I'm just trying to
help you as far as I can.

HTH


--
Casey


------------------------------------------------------------------------
Casey's Profile: http://www.excelforum.com/member.php...fo&userid=4545
View this thread: http://www.excelforum.com/showthread...hreadid=557353



All times are GMT +1. The time now is 03:46 AM.

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