#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Command Buttons

I am trying to insert a command button so that when the user fills out the
form and clicks the button, an amount will calculate. For example, the sales
price is in A1, when the user clicks the command button, the sales price will
be divided by 1000 then divided by 2 and the answer will appear in A5. Can
anyone help????
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Command Buttons

You can do that with a simple formula in A5 and no command button but if you
want a button.

Assign this macro to a button from the Forms Toolbar.

Sub divide()
With ActiveSheet
.Range("A5").Value = Range("A1").Value / 2000
End With
End Sub


Gord Dibben MS Excel MVP

On Tue, 25 May 2010 08:58:01 -0700, Command Button Calculations <Command
Button wrote:

I am trying to insert a command button so that when the user fills out the
form and clicks the button, an amount will calculate. For example, the sales
price is in A1, when the user clicks the command button, the sales price will
be divided by 1000 then divided by 2 and the answer will appear in A5. Can
anyone help????


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default Command Buttons

Sub xlcalcit()
Dim c As Double
c = [A1].Value
c = c / 1000
c = c / 2
[A5].Value = c
End Sub

regards
FSt1

"Command Button Calculations" wrote:

I am trying to insert a command button so that when the user fills out the
form and clicks the button, an amount will calculate. For example, the sales
price is in A1, when the user clicks the command button, the sales price will
be divided by 1000 then divided by 2 and the answer will appear in A5. Can
anyone help????

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Command Buttons

Just a minor typing change.

Sub divide()
With ActiveSheet
.Range("A5").Value = .Range("A1").Value / 2000
End With
End Sub

I added the dot in front of the .range("A1")... stuff.

But even without this dot, the code would work fine -- since you're using the
activesheet and the code is in a general module.

But it's never a bad idea to qualify ranges/objects <vbg.

Gord Dibben wrote:

You can do that with a simple formula in A5 and no command button but if you
want a button.

Assign this macro to a button from the Forms Toolbar.

Sub divide()
With ActiveSheet
.Range("A5").Value = Range("A1").Value / 2000
End With
End Sub

Gord Dibben MS Excel MVP

On Tue, 25 May 2010 08:58:01 -0700, Command Button Calculations <Command
Button wrote:

I am trying to insert a command button so that when the user fills out the
form and clicks the button, an amount will calculate. For example, the sales
price is in A1, when the user clicks the command button, the sales price will
be divided by 1000 then divided by 2 and the answer will appear in A5. Can
anyone help????


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Command Buttons

Thanks Dave.


Gord

On Tue, 25 May 2010 12:02:02 -0500, Dave Peterson
wrote:

Just a minor typing change.

Sub divide()
With ActiveSheet
.Range("A5").Value = .Range("A1").Value / 2000
End With
End Sub

I added the dot in front of the .range("A1")... stuff.

But even without this dot, the code would work fine -- since you're using the
activesheet and the code is in a general module.

But it's never a bad idea to qualify ranges/objects <vbg.

Gord Dibben wrote:

You can do that with a simple formula in A5 and no command button but if you
want a button.

Assign this macro to a button from the Forms Toolbar.

Sub divide()
With ActiveSheet
.Range("A5").Value = Range("A1").Value / 2000
End With
End Sub

Gord Dibben MS Excel MVP

On Tue, 25 May 2010 08:58:01 -0700, Command Button Calculations <Command
Button wrote:

I am trying to insert a command button so that when the user fills out the
form and clicks the button, an amount will calculate. For example, the sales
price is in A1, when the user clicks the command button, the sales price will
be divided by 1000 then divided by 2 and the answer will appear in A5. Can
anyone help????


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
Command Buttons aussiegirlone Excel Discussion (Misc queries) 3 January 11th 09 01:56 AM
Command Buttons Hoyas07 Excel Discussion (Misc queries) 2 February 11th 08 03:42 PM
Command Buttons msals22 Excel Discussion (Misc queries) 1 June 22nd 06 01:33 AM
Help with command buttons Danno Excel Worksheet Functions 1 October 7th 05 10:32 PM
command buttons Natalie Excel Worksheet Functions 1 March 7th 05 01:45 PM


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

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"