PC Review


Reply
Thread Tools Rate Thread

CommandButtons relocate on worksheet when code runs ??

 
 
Corey
Guest
Posts: n/a
 
      4th May 2007
Just recently i have found that when i use a button to chech the number of pages needed to print
and print them,
ALL (but 1) CommandButton moves fromt he Right side to the left side of the page?


Why is it so?

Sub PrintReport() ' prints report worksheet
Call SetPrintAreaR
If Cells(22, 1).Value < 1 Then
Exit Sub
Else
ActiveWindow.ActiveSheet.PrintOut Copies:=1, Collate:=True
End If
End Sub

~~~~~~~~~~~~~~~~~~~~~~~~~~

Sub SetPrintAreaR() ' sets print area of Map according to No. of events
If Cells(22, 1).Value = 0 Then
ActiveSheet.PageSetup.PrintArea = "$A$1:$H$26" ' base area
MsgBox "There are No Events detected in the Report! ", vbOKOnly, sTitle ' warning
Else
ActiveSheet.PageSetup.PrintArea = "$A$1:$H$" & ((Cells(22, 1).Value * 4) + 22) ' calculates
where entered events cease
End If
End Sub


 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      4th May 2007
Corey,
If this XL 2002 with SP3, here's a couple of solutions:

http://www.xtremevbtalk.com/showthread.php?t=191926
http://support.microsoft.com/?kbid=838910
but seems a hot-fix is available.

NickHK

"Corey" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Just recently i have found that when i use a button to chech the number of

pages needed to print
> and print them,
> ALL (but 1) CommandButton moves fromt he Right side to the left side of

the page?
>
>
> Why is it so?
>
> Sub PrintReport() ' prints report worksheet
> Call SetPrintAreaR
> If Cells(22, 1).Value < 1 Then
> Exit Sub
> Else
> ActiveWindow.ActiveSheet.PrintOut Copies:=1, Collate:=True
> End If
> End Sub
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Sub SetPrintAreaR() ' sets print area of Map according to No. of events
> If Cells(22, 1).Value = 0 Then
> ActiveSheet.PageSetup.PrintArea = "$A$1:$H$26" ' base area
> MsgBox "There are No Events detected in the Report! ", vbOKOnly,

sTitle ' warning
> Else
> ActiveSheet.PageSetup.PrintArea = "$A$1:$H$" & ((Cells(22, 1).Value

* 4) + 22) ' calculates
> where entered events cease
> End If
> End Sub
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy worksheet WITH CommandButtons within Workbook DonJ_Austin Microsoft Excel Programming 0 19th Feb 2009 05:47 PM
CommandButtons relocate when printing Corey Microsoft Excel Programming 1 7th May 2007 07:45 AM
When code runs...worksheet acts a little strange KimberlyC Microsoft Excel Programming 3 1st Apr 2005 04:49 PM
commandbuttons on worksheet move to the left KRCowen Microsoft Excel Programming 3 26th Sep 2004 04:10 PM
VBA code that only runs when a worksheet is active Paul James Microsoft Excel Programming 4 11th Dec 2003 01:05 AM


Features
 

Advertising
 

Newsgroups
 


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