expected variable or Function

Kawg

New Member
Joined
Oct 14, 2004
Messages
12
Hey all,

I have a strange problem (or I should say strange to me) and I am hoping some one can shed some light on it, I am hung up on a couple of macros:

I have two macros with the following code in the beginning:

Rows("1:1").Select
Selection.Insert Shift:=xlDOWN

When I execute them, I get an error that reads 'expected Function or variable' and it highlights the above line, 'xlDOWN'.

I ran these macros successfully before, so I don't know what could be the issue. Any input helpful,

Thanks,

Kawg
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi Kawg,

I recommend you use:

Rows(1).Insert

It is unnecessary to do the select. In addition, since the range is an entire row, shifting down is the only option. The shift argument only needs to be used when you are inserting cells, not complete rows or columns. Also, the constant xlDOWN should have been xlShiftDown.
 
Upvote 0
Thanks, Damon,

Since I don't know how to write vb I record the macro and go in to clean it up. For some reason that macro worked with the code as it was and mysteriously started putting up an error message.

Thanks for clearing it up!

Kawg
 
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top