Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Programming command button to execute on a different worksheet

I have made a complex workbook that consists of multiple
command buttons. I an needing the program a command
button to (.ClearContents) of certain cells on a
different worksheet.
Within a work sheet the code is as follows:
Range ("C1:C5").ClearContents
Is there anyone out there that can tell me how to execute
this from one worksheet to another.
Example:
Button is on worksheet "1" and I need to clear contents
on worksheet "2".
Thanks for your help in advance
Ed

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Programming command button to execute on a different worksheet

Hi Ed,

You can (and should in most circumstances) preface the Range with a
Worksheet object:

Worksheets("Sheet2").Range("C1:C5").ClearContents

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Ed wrote:
I have made a complex workbook that consists of multiple
command buttons. I an needing the program a command
button to (.ClearContents) of certain cells on a
different worksheet.
Within a work sheet the code is as follows:
Range ("C1:C5").ClearContents
Is there anyone out there that can tell me how to execute
this from one worksheet to another.
Example:
Button is on worksheet "1" and I need to clear contents
on worksheet "2".
Thanks for your help in advance
Ed


  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Programming command button to execute on a different worksheet

Thanks for your help Jake
Sometimes it is the simple things that make no sense
after you stare at the screen long enough.
Thanks again
Ed
-----Original Message-----
Hi Ed,

You can (and should in most circumstances) preface the

Range with a
Worksheet object:

Worksheets("Sheet2").Range("C1:C5").ClearContents

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address

unmonitored]


Ed wrote:
I have made a complex workbook that consists of

multiple
command buttons. I an needing the program a command
button to (.ClearContents) of certain cells on a
different worksheet.
Within a work sheet the code is as follows:
Range ("C1:C5").ClearContents
Is there anyone out there that can tell me how to

execute
this from one worksheet to another.
Example:
Button is on worksheet "1" and I need to clear contents
on worksheet "2".
Thanks for your help in advance
Ed


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Programming command button to execute on a different worksheet

wrote:
Thanks for your help Jake
Sometimes it is the simple things that make no sense
after you stare at the screen long enough.
Thanks again


No problem, Ed - glad to help.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
  #5   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default Programming command button to execute on a different worksheet

You can prompt the user to enter a sheet number.

Private Sub CommandButton1_Click()
Dim SheetNum As Integer

'If user enters other than a number, or number too
high, procedure will exit without changes.
On Error GoTo EndIt
SheetNum = InputBox("Enter sheet number", , 1)
ThisWorkbook.Worksheets(SheetNum).Range
("A4:A6").ClearContents
EndIt:
End Sub

One problem is that sheet numbers may not always be in
order. But hopefully this'll give you the idea.

tod

-----Original Message-----
I have made a complex workbook that consists of multiple
command buttons. I an needing the program a command
button to (.ClearContents) of certain cells on a
different worksheet.
Within a work sheet the code is as follows:
Range ("C1:C5").ClearContents
Is there anyone out there that can tell me how to execute
this from one worksheet to another.
Example:
Button is on worksheet "1" and I need to clear contents
on worksheet "2".
Thanks for your help in advance
Ed

.



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
Counting, command button and programming in VB ElFrodo Excel Discussion (Misc queries) 5 February 23rd 07 05:24 AM
Programming a "Save as..." command button within Excel DavidHawes Excel Discussion (Misc queries) 2 November 13th 06 02:48 PM
How do I add a command button on a worksheet to "paste" from the . Jalifid Excel Worksheet Functions 0 March 13th 05 03:01 PM
How do I execute command from button or hyperlink? rerhart Excel Discussion (Misc queries) 1 February 18th 05 09:41 PM
Hide command button on worksheet Mohair Excel Programming 3 July 14th 03 11:06 PM


All times are GMT +1. The time now is 04:37 AM.

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

About Us

"It's about Microsoft Excel"