PDA

View Full Version : [SOLVED:] VBA changes "Rows" to "rows"



smylex
08-20-2018, 06:00 AM
Hello,
I'm new to VBA, so I record my macros and try to see how they work.
My problem is I'm trying to insert a new row and VBA recorded this:


rows("1:1").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove

and when I run it I get the message "Wrong number of arguments or invalid property assignment" and "rows" gets highlighted.
I know Rows() should have capital R, but when I change it, VBA turns it back to small letters.
Could anyone help me with this?
Thank you

p45cal
08-20-2018, 01:57 PM
You've probably declared rows as a variable somewhere, perhaps in a Dim line in the code.
Do a search in the code for rows with lower case:
In the VBE, Ctrl+f brings up the search dialoque; type in row, search Current Project, All direction, match case if you want, Find Next repeated clicks should eventually bring up the offending line.

p45cal
08-21-2018, 07:04 AM
Forgot to mention a few things:
1. It could also be that you created a function called rows
2. After you've deleted/changed all your created rows, the VBE is likely still to convert your Rows to rows, however, you should no longer get the error thrown.
3. Another thing you can try is to put the cursor on the word rows, then on the keyboard press Shift+F2, which should take you to where rows is defined.

smylex
08-21-2018, 10:10 AM
It turned out that my file had another macro in it and indeed "rows" was in a function. Shift+F2 really helped.
So now it's solved.
Thank you.