#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 17
Default command button code

I have this formula in cell B9
=IF(B10="","",IF(B9="",NOW(),B9))
This puts the current time(remaining static) in B9 anytime something is
entered into B10.
What I would like to do is have one of the command buttons or check boxes in
B10 that would trigger the action.
Thanks for any help.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default command button code

Here is the coding for your button. Note that with the macro, you no longer
need the formula in cell B9:

'===============
Sub UpdateTime()
'Original formula for reference
'=IF(B10="","",IF(B9="",NOW(),B9))

If Range("B10") = "" Then
x = ""
ElseIf Range("B9") = "" Then
x = Now
Else: x = Range("B9")
End If
Range("B9") = x
End Sub
'===========
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"dummy" wrote:

I have this formula in cell B9
=IF(B10="","",IF(B9="",NOW(),B9))
This puts the current time(remaining static) in B9 anytime something is
entered into B10.
What I would like to do is have one of the command buttons or check boxes in
B10 that would trigger the action.
Thanks for any help.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 17
Default command button code

I'm getting a "compile error" "expected end sub". I copied and pasted your
code between :

Private Sub CommandButton1_Click()

End Sub

Is that correct?

"Luke M" wrote:

Here is the coding for your button. Note that with the macro, you no longer
need the formula in cell B9:

'===============
Sub UpdateTime()
'Original formula for reference
'=IF(B10="","",IF(B9="",NOW(),B9))

If Range("B10") = "" Then
x = ""
ElseIf Range("B9") = "" Then
x = Now
Else: x = Range("B9")
End If
Range("B9") = x
End Sub
'===========
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"dummy" wrote:

I have this formula in cell B9
=IF(B10="","",IF(B9="",NOW(),B9))
This puts the current time(remaining static) in B9 anytime something is
entered into B10.
What I would like to do is have one of the command buttons or check boxes in
B10 that would trigger the action.
Thanks for any 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 code ( GOTO command) in formula calan New Users to Excel 1 June 11th 09 09:44 AM
Code for my Command Button to automatically copy and insert a new tommy Excel Discussion (Misc queries) 0 January 28th 09 12:22 AM
Command button to toggle worksheet event code on / off? Fred[_2_] Excel Discussion (Misc queries) 15 July 31st 07 11:50 AM
VBA code behind command button [email protected] Excel Worksheet Functions 1 March 22nd 06 08:13 PM
Command Button VBA code Dave Peterson Excel Discussion (Misc queries) 2 January 25th 05 11:28 PM


All times are GMT +1. The time now is 08:38 AM.

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"