Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
If/Then/Else formulas in macros
I am new to VB/macros but want to know if this is possible. I have created a workbook to quickly and easily record times for runners. I have assigned a macro to a button titled "start" which inserts the current time in cell A1. Then I have created several numbered buttons that put the current time next to a runners name. A formula subtracts the difference to get the time. What I now want to do is be able to get a split time by pressing the button for a second time. What I need the macro to do is on the first press of a button put the current time in cell A3, on the second press of the same button place the current time in cell B3, and on the third press of the same button place the current time in cell C3. Is this possible and how, or is there a better way to accomplish this? Here is the current macro I recorded. Sub Finish_01() ' ' Finish_01 Macro ' Macro recorded 10/11/2005 by CJ_22 ' ' Range("F5").Select Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "=NOW()" Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("A1").Select End Sub Thanks for any reply. -- CJ-22 ------------------------------------------------------------------------ CJ-22's Profile: http://www.excelforum.com/member.php...o&userid=17551 View this thread: http://www.excelforum.com/showthread...hreadid=503191 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
If/Then/Else formulas in macros
Hi there,
If you do not have anything else in row 3, you could use something like this .... Sub try_this() Cells(3, columns.count).end(xltoleft).offset(0, 1).value = time End sub Format row 3 as desired. HTH -- Regards, Zack Barresse, aka firefytr "CJ-22" wrote in message ... I am new to VB/macros but want to know if this is possible. I have created a workbook to quickly and easily record times for runners. I have assigned a macro to a button titled "start" which inserts the current time in cell A1. Then I have created several numbered buttons that put the current time next to a runners name. A formula subtracts the difference to get the time. What I now want to do is be able to get a split time by pressing the button for a second time. What I need the macro to do is on the first press of a button put the current time in cell A3, on the second press of the same button place the current time in cell B3, and on the third press of the same button place the current time in cell C3. Is this possible and how, or is there a better way to accomplish this? Here is the current macro I recorded. Sub Finish_01() ' ' Finish_01 Macro ' Macro recorded 10/11/2005 by CJ_22 ' ' Range("F5").Select Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "=NOW()" Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("A1").Select End Sub Thanks for any reply. -- CJ-22 ------------------------------------------------------------------------ CJ-22's Profile: http://www.excelforum.com/member.php...o&userid=17551 View this thread: http://www.excelforum.com/showthread...hreadid=503191 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macros and Formulas | Excel Worksheet Functions | |||
using formulas in macros | Excel Discussion (Misc queries) | |||
formulas vs macros | Excel Discussion (Misc queries) | |||
Macros within formulas | Excel Programming | |||
formulas to macros | Excel Programming |