Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default problems when moving code from Macro to Command button on sheet

You could have the CommandButton call the macro that works.

The problem is likely this line:

Set myC = Range("I6:I233").Find(What:="", LookAt:=xlWhole)

Excel takes the range to be on whatever the active sheet is.

If you change it to:

Set myC = Worksheets.("Printout").Range("I6:I233").Find(What :="",
LookAt:=xlWhole)

the range is better specified.

HTH,
Merjet

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default problems when moving code from Macro to Command button on shee

I didn't get a runtime error on the modified line:
Set myC = Worksheets("Printout").Range("I6:I233").Find(What: ="",
LookAt:=xlWhole)

However, I did on this one:
Range(myC, Range("I233")).Resize(, 5).Delete Shift:=xlUp

until I also modified it to:
Worksheets("Printout").Range(myC,
Worksheets("Printout").Range("I233")).Resize(, 5).Delete Shift:=xlUp

HTH,
Merjet

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
moved vba code from macro to command button, now won't work Charles Chickering Excel Programming 0 January 12th 07 10:18 PM
Code created in a Macro not working for a Command Button Amber_D_Laws[_8_] Excel Programming 15 January 13th 06 10:35 PM
Excel - keep a command button from moving after code runs? Dave Little Excel Programming 1 October 28th 05 02:16 PM
macro code doesnt work in command button The Grinch[_9_] Excel Programming 4 July 22nd 04 06:28 PM
generating sheet with command button & code Bob[_27_] Excel Programming 4 August 4th 03 02:46 PM


All times are GMT +1. The time now is 05:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"