#1
|
|||
|
|||
Code looks like it should work, but don't
Baffled why the following code doesn't work.
ActiveWorkbook.Sheets("XXXX ").Activate Sheets("XXXX").Select ActiveSheet.Range("A7").Select ActiveCell.EntireRow.Insert Thanks in advance for any explaination |
#2
|
|||
|
|||
What's your definition of "doesn't work" ?
When I rename 2 sheets in my workbook, one XXXX and the other XXXX and a space all 4 lines of code execute as expected for me. |
#3
|
|||
|
|||
What I have discovered is that this code works and then doesn't work. By work. I mean not getting an error. Thank you for your reply, because now I now that the code is good and there is some other issue. I have googled and found another person has had the same problem.
|
#4
|
|||
|
|||
Out of curiosity, what does the debugger message say the error is ?
|
#5
|
|||
|
|||
insert method of range class failed
|
#6
|
|||
|
|||
I'm not able to setup anything that will produce that error. My gut feeling was merged cells could cause this, but apparently not.
Googling seems to indicate others with 'Method of range class failed' errors manage to eliminate the error issue by not using .Select, which is seldom necessary anyway. In your case Code:
Sheets("XXXX").Range("A7").EntireRow.Insert |
#7
|
|||
|
|||
Maybe post a sample workbook with the code to show it not working as you would expect.
|
#8
|
|||
|
|||
NoSparks
THANKS . APPRECIATE YOU INPUTS |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Code doesnt work properly | ksigcajun | Word VBA | 6 | 04-06-2015 07:41 AM |
Can't make code work. | gbaker | Excel Programming | 2 | 07-13-2012 10:01 PM |
Will VBA code work in a web browser? | PeligrosoBlanco | PowerPoint | 1 | 03-28-2012 11:57 PM |
My Product code doesnt work!!!! PLEASE HELP | dukquaknoobhack | Office | 1 | 01-05-2012 03:43 PM |
simple code doesn't work help | piper7971 | PowerPoint | 2 | 08-19-2010 08:15 AM |