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
 

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Damon Ostrander

MrExcel MVP
Joined
Feb 17, 2002
Messages
4,239
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.
 

Kawg

New Member
Joined
Oct 14, 2004
Messages
12
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
 

Watch MrExcel Video

Forum statistics

Threads
1,123,481
Messages
5,601,918
Members
414,482
Latest member
morkar

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
Top