Spinner

A

art

Hello:

I need help adding a min to a spinner. I want to add to the code that the
spinner should not go below 0, that means it should not go -1, -2, -3 and so
on. Below is the vba code I have for the spinner button:

Sub Button1_Click()
'
' Button1_Click Macro
'

'Private Sub SpinButton1_SpinDown()
ActiveCell.Value = ActiveCell.Value - 1
End Sub

Private Sub SpinButton1_SpinUp()
ActiveCell.Value = ActiveCell.Value + 1
SpinButton.Min ["=5"]
End Sub
 
O

Office_Novice

Try this

private Sub SpinButton1_SpinDown()
If ActiveCell.Value <= 0 Then
Exit Sub
Else
ActiveCell.Value = ActiveCell.Value - 1
End If
End Sub

Private Sub SpinButton1_SpinUp()
ActiveCell.Value = ActiveCell.Value + 1
End Sub
 
A

art

Thanks, just one more thing. How about, if it is less then 1, then leave
empty without a zero? Can you add that for me as well?

Office_Novice said:
Try this

private Sub SpinButton1_SpinDown()
If ActiveCell.Value <= 0 Then
Exit Sub
Else
ActiveCell.Value = ActiveCell.Value - 1
End If
End Sub

Private Sub SpinButton1_SpinUp()
ActiveCell.Value = ActiveCell.Value + 1
End Sub


art said:
Hello:

I need help adding a min to a spinner. I want to add to the code that the
spinner should not go below 0, that means it should not go -1, -2, -3 and so
on. Below is the vba code I have for the spinner button:

Sub Button1_Click()
'
' Button1_Click Macro
'

'Private Sub SpinButton1_SpinDown()
ActiveCell.Value = ActiveCell.Value - 1
End Sub

Private Sub SpinButton1_SpinUp()
ActiveCell.Value = ActiveCell.Value + 1
SpinButton.Min ["=5"]
End Sub
 
O

Office_Novice

Private Sub SpinButton1_SpinDown()
If ActiveCell.Value <= 1 Then
ActiveCell = ""
Else
ActiveCell.Value = ActiveCell.Value - 1
End If
End Sub

Private Sub SpinButton1_SpinUp()
ActiveCell.Value = ActiveCell.Value + 1
End Sub
 
R

Rick Rothstein \(MVP - VB\)

Try this SpinDown code instead (the SpinUp code is you already have is
fine)...

Private Sub SpinButton1_SpinDown()
If SpinButton1.Value > 0 Then
ActiveCell.Value = ActiveCell.Value - 1
Else
ActiveCell.Value = ""
End If
End Sub

Rick


art said:
Thanks, just one more thing. How about, if it is less then 1, then leave
empty without a zero? Can you add that for me as well?

Office_Novice said:
Try this

private Sub SpinButton1_SpinDown()
If ActiveCell.Value <= 0 Then
Exit Sub
Else
ActiveCell.Value = ActiveCell.Value - 1
End If
End Sub

Private Sub SpinButton1_SpinUp()
ActiveCell.Value = ActiveCell.Value + 1
End Sub


art said:
Hello:

I need help adding a min to a spinner. I want to add to the code that
the
spinner should not go below 0, that means it should not go -1, -2, -3
and so
on. Below is the vba code I have for the spinner button:

Sub Button1_Click()
'
' Button1_Click Macro
'

'Private Sub SpinButton1_SpinDown()
ActiveCell.Value = ActiveCell.Value - 1
End Sub

Private Sub SpinButton1_SpinUp()
ActiveCell.Value = ActiveCell.Value + 1
SpinButton.Min ["=5"]
End Sub
 
A

art

Thanks a million.

Office_Novice said:
Private Sub SpinButton1_SpinDown()
If ActiveCell.Value <= 1 Then
ActiveCell = ""
Else
ActiveCell.Value = ActiveCell.Value - 1
End If
End Sub

Private Sub SpinButton1_SpinUp()
ActiveCell.Value = ActiveCell.Value + 1
End Sub

art said:
Hello:

I need help adding a min to a spinner. I want to add to the code that the
spinner should not go below 0, that means it should not go -1, -2, -3 and so
on. Below is the vba code I have for the spinner button:

Sub Button1_Click()
'
' Button1_Click Macro
'

'Private Sub SpinButton1_SpinDown()
ActiveCell.Value = ActiveCell.Value - 1
End Sub

Private Sub SpinButton1_SpinUp()
ActiveCell.Value = ActiveCell.Value + 1
SpinButton.Min ["=5"]
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top