Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-22-2017, 10:25 PM
FUGMAN FUGMAN is offline Code looks like it should work, but don't Windows 10 Code looks like it should work, but don't Office 2016
Banned
Code looks like it should work, but don't
 
Join Date: Feb 2017
Posts: 55
FUGMAN is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 02-22-2017, 11:38 PM
NoSparks NoSparks is offline Code looks like it should work, but don't Windows 7 64bit Code looks like it should work, but don't Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

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.
Reply With Quote
  #3  
Old 02-23-2017, 07:05 AM
FUGMAN FUGMAN is offline Code looks like it should work, but don't Windows 10 Code looks like it should work, but don't Office 2016
Banned
Code looks like it should work, but don't
 
Join Date: Feb 2017
Posts: 55
FUGMAN is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 02-23-2017, 08:43 AM
NoSparks NoSparks is offline Code looks like it should work, but don't Windows 7 64bit Code looks like it should work, but don't Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

Out of curiosity, what does the debugger message say the error is ?
Reply With Quote
  #5  
Old 02-23-2017, 09:04 AM
FUGMAN FUGMAN is offline Code looks like it should work, but don't Windows 10 Code looks like it should work, but don't Office 2016
Banned
Code looks like it should work, but don't
 
Join Date: Feb 2017
Posts: 55
FUGMAN is on a distinguished road
Default

insert method of range class failed
Reply With Quote
  #6  
Old 02-23-2017, 09:56 AM
NoSparks NoSparks is offline Code looks like it should work, but don't Windows 7 64bit Code looks like it should work, but don't Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

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
would suffice. Don't know if this will help or not, it's just a thought.
Reply With Quote
  #7  
Old 02-23-2017, 04:21 PM
jeffreybrown jeffreybrown is offline Code looks like it should work, but don't Windows Vista Code looks like it should work, but don't Office 2007
Expert
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Maybe post a sample workbook with the code to show it not working as you would expect.
Reply With Quote
  #8  
Old 02-23-2017, 07:08 PM
FUGMAN FUGMAN is offline Code looks like it should work, but don't Windows 10 Code looks like it should work, but don't Office 2016
Banned
Code looks like it should work, but don't
 
Join Date: Feb 2017
Posts: 55
FUGMAN is on a distinguished road
Default

NoSparks

THANKS .

APPRECIATE YOU INPUTS
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Code looks like it should work, but don't 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
Code looks like it should work, but don't 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:32 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft