Haven't tested this but the OnTime macro is a string, not a direct
reference
Public Sub ManualSwap(SwapPosition As Integer)
If FirstButtonPress = 0 Then
FirstButtonPress = SwapPosition
Range("B2").Select
Selection.Value = FirstButtonPress
'give the user 4 seconds to choose the second range in the swap
Application.OnTime Now + TimeValue("00:00:4"), _
"ResetTheFirstManualSwapButton"
Else
'There are now 2 variables for the 2 ranges
'run some code here to swap the ranges
'set the to FirstButtonPress = 0 ready for the next swap
FirstButtonPress = 0
Range("B2").Select
Selection.Value = FirstButtonPress
End If
End Sub
'************************************************** *****
Public Function ResetTheFirstManualSwapButton()
' the user waited too long so reset the to FirstButtonPress = 0
Dim FirstButtonPress As Integer
FirstButtonPress = 0
Range("B2").Select
Selection.Value = FirstButtonPress
End Function
--
HTH
Bob Phillips
(replace somewhere in email address with gmail if mailing direct)
"SuitedAces" <SuitedAces.2a5ih0_1151563502.8894@excelforum-nospam.com> wrote
in message news:SuitedAces.2a5ih0_1151563502.8894@excelforum-nospam.com...
>
> *Please help with this*, I am using 2 button presses to swap ranges
> ( I have 30 ranges and 30 buttons)
> and I am using Ontime to kill and reset the code if the user doesn't
> press the second button within 4 seconds of the first button press.
>
> They way I am using the Ontime function is taken directly
> out of EXCEL help yet it results in .... unable to find the function
> (ResetTheFirstManualSwapButton)
>
> I only am setting the values in B2 just to watch the results of the
> flow of the code before I add the code needed to do the swapping
>
> ************************************************** *****
> Public Sub ManualSwap(SwapPosition As Integer)
>
> If FirstButtonPress = 0 Then
>
> FirstButtonPress = SwapPosition
> Range("B2").Select
> Selection.Value = FirstButtonPress
> 'give the user 4 seconds to choose the second range in the swap
> 'Application.OnTime Now + TimeValue("00:00:4"),
> ResetTheFirstManualSwapButton
>
> Else
>
> 'There are now 2 variables for the 2 ranges
> 'run some code here to swap the ranges
> 'set the to FirstButtonPress = 0 ready for the next swap
> FirstButtonPress = 0
> Range("B2").Select
> Selection.Value = FirstButtonPress
>
> End If
>
> End Sub
> ************************************************** *****
> Public Function ResetTheFirstManualSwapButton()
> ' the user waited too long so reset the to FirstButtonPress = 0
> Dim FirstButtonPress As Integer
> FirstButtonPress = 0
> Range("B2").Select
> Selection.Value = FirstButtonPress
> End Function
>
> If I can get past this obstacle I will be able to complete the code for
> these
> swap buttons. *Your help is appreciated*
>
>
> --
> SuitedAces
> ------------------------------------------------------------------------
> SuitedAces's Profile:
http://www.excelforum.com/member.php...o&userid=35840
> View this thread: http://www.excelforum.com/showthread...hreadid=556796
>
Bookmarks