hey guys, so i need a little help with a macro for excel, i have got it to do what i want it to do but i want to restrict it, heres the code for the macro:Sub Macro1()
Dim t
t = Split(Worksheets("Sheet1").Range("d5").Text, "/")
t(0) = Format(t(0) + 1, "0")
Worksheets("Sheet1").Range("d5") = Join(t, "/")
'
End Sub
Sub Macro2()
Dim t
t = Split(Worksheets("Sheet1").Range("d5").Text, "/")
t(0) = Format(t(0) - 1, "0")
Worksheets("Sheet1").Range("d5") = Join(t, "/")
'
End Sub '
so macro1 +1 to d5 and macro 2 subtracts 1, the restriction i want to put onto it is say d5 = 0 i dont want to be able to subtract from it, i want to put a maximum restriction on it to so say d5 = 20 i dont want it to be able to add any more to it, is it possibe to do something like this with macro's???edit:
figured out how to do it, for whoever it mat concern the code now looks like this:
Sub Macro1()
Dim t
t = Split(Worksheets("Sheet1").Range("d5").Text, "/")
If Not t(0) = 5 Then
t(0) = Format(t(0) + 1, "0")
Worksheets("Sheet1").Range("d5") = Join(t, "/")
End If
'
End Sub
Sub Macro2()
Dim t
t = Split(Worksheets("Sheet1").Range("d5").Text, "/")
If Not t(0) = 0 Then
t(0) = Format(t(0) - 1, "0")
Worksheets("Sheet1").Range("d5") = Join(t, "/")
End If
'
End Sub '
I would have helped, but for all the programming I know, I still know nothing about Excel. I never use it.
its cool :D excel uses vb, the one that i hate most of all :P