Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
T K T K is offline
external usenet poster
 
Posts: 2
Default Command Button vs Form Button

Hi:
Please Assume:
a Workbook named Invoice and Worksheets named "Invoice"
and "Parts List"
a Form Button Object and a Command Button on the
("Invoice") Sheet

The following Macro attached to the form button works as
expected .

Sub test1()

' test1 Macro
' Shortcut: Ctrl+z
Sheets("Parts List").Select
Range("U3:U51").Select
Selection.Copy
Range("E3").Select
Selection.PasteSpecial Paste:=xlValues,
Operation:=xlAdd, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Range("G22").Select
Sheets("Invoice").Select
Range("D7").Select

End Sub

The same code attached to the Command Button does not
work even if I fully quality the Workbook or try to as
follows

Private Sub CommandButton1_Click()

'( Application.Workbooks("Invoice.xls").Worksheets("P arts
List"). Range("U3:U51").Select)

Sheets("Parts List").Select
....
...
Range("D7").Select

End Sub

Any help or direction will be greatly appreciated

T K

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Command Button vs Form Button

Just copy the the code and paste it into the command button code
(leave out Sub test1() and End Sub)

or use
Run test1
provided test1 is in a standard module.

If test1 is in module1, I like to use
Module1.Test1
to run a macro.

--
sb
"T K" wrote in message
...
Hi:
Please Assume:
a Workbook named Invoice and Worksheets named "Invoice"
and "Parts List"
a Form Button Object and a Command Button on the
("Invoice") Sheet

The following Macro attached to the form button works as
expected .

Sub test1()

' test1 Macro
' Shortcut: Ctrl+z
Sheets("Parts List").Select
Range("U3:U51").Select
Selection.Copy
Range("E3").Select
Selection.PasteSpecial Paste:=xlValues,
Operation:=xlAdd, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Range("G22").Select
Sheets("Invoice").Select
Range("D7").Select

End Sub

The same code attached to the Command Button does not
work even if I fully quality the Workbook or try to as
follows

Private Sub CommandButton1_Click()

'( Application.Workbooks("Invoice.xls").Worksheets("P arts
List"). Range("U3:U51").Select)

Sheets("Parts List").Select
....
...
Range("D7").Select

End Sub

Any help or direction will be greatly appreciated

T K



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Command Button vs Form Button

Just copy the the code and paste it into the command button code
(leave out Sub test1() and End Sub)


since the code has unqualified references that appear to refer to two
separate sheets, the code will need some adjustment. Just calling Test from
the sheet module would avoid that.

--
Regards,
Tom Ogilvy


"steve" wrote in message
...
Just copy the the code and paste it into the command button code
(leave out Sub test1() and End Sub)

or use
Run test1
provided test1 is in a standard module.

If test1 is in module1, I like to use
Module1.Test1
to run a macro.

--
sb
"T K" wrote in message
...
Hi:
Please Assume:
a Workbook named Invoice and Worksheets named "Invoice"
and "Parts List"
a Form Button Object and a Command Button on the
("Invoice") Sheet

The following Macro attached to the form button works as
expected .

Sub test1()

' test1 Macro
' Shortcut: Ctrl+z
Sheets("Parts List").Select
Range("U3:U51").Select
Selection.Copy
Range("E3").Select
Selection.PasteSpecial Paste:=xlValues,
Operation:=xlAdd, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Range("G22").Select
Sheets("Invoice").Select
Range("D7").Select

End Sub

The same code attached to the Command Button does not
work even if I fully quality the Workbook or try to as
follows

Private Sub CommandButton1_Click()

'( Application.Workbooks("Invoice.xls").Worksheets("P arts
List"). Range("U3:U51").Select)

Sheets("Parts List").Select
....
...
Range("D7").Select

End Sub

Any help or direction will be greatly appreciated

T K





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Command Button vs Form Button

Private Sub CommandButton1_Click()
Sheets("Parts List").Range("U3:U51").Copy
Sheets("Parts List").Range("E3") _
.PasteSpecial Paste:=xlValues, _
Operation:=xlAdd, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Sheets("Invoice").Select
Sheets("Invoice").Range("D7").Select
End Sub


--
Regards,
Tom Ogilvy

"T K" wrote in message
...
Hi:
Please Assume:
a Workbook named Invoice and Worksheets named "Invoice"
and "Parts List"
a Form Button Object and a Command Button on the
("Invoice") Sheet

The following Macro attached to the form button works as
expected .

Sub test1()

' test1 Macro
' Shortcut: Ctrl+z
Sheets("Parts List").Select
Range("U3:U51").Select
Selection.Copy
Range("E3").Select
Selection.PasteSpecial Paste:=xlValues,
Operation:=xlAdd, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Range("G22").Select
Sheets("Invoice").Select
Range("D7").Select

End Sub

The same code attached to the Command Button does not
work even if I fully quality the Workbook or try to as
follows

Private Sub CommandButton1_Click()

'( Application.Workbooks("Invoice.xls").Worksheets("P arts
List"). Range("U3:U51").Select)

Sheets("Parts List").Select
....
...
Range("D7").Select

End Sub

Any help or direction will be greatly appreciated

T K



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
macro attached to command button - VBA form Roy Gudgeon[_2_] Excel Discussion (Misc queries) 2 March 16th 10 12:44 PM
opening a worksheet with a command button on a form gbpg Excel Discussion (Misc queries) 2 September 1st 07 05:40 AM
User form and Command button Marilyn Excel Discussion (Misc queries) 3 May 9th 07 12:50 AM
Command Button on User form for Printing Anthony Slater Excel Discussion (Misc queries) 2 September 7th 05 02:01 PM
Command button on data-entry form Susy Excel Discussion (Misc queries) 1 February 15th 05 01:46 AM


All times are GMT +1. The time now is 08:05 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"