"marty6 " wrote in message
...
Bob Phillips,
Thank you for the reply!
I still need alittle help with this though. Could you walk me throught
this example?
Would it be like this?
Private Sub Commandbutton1_Click()
IncDec txt1Add, True
IncDec txt1Subtract, False
IncDec txt2Add, True
IncDec txt2Subtract, False
IncDec txt3Add, True
IncDec txt3Subtract, False
etc... until all 14 textboxes are written here?
****the IncDec txt1 refers to the textfields correct?**** So, if I
have 14 fields, I'll have 28 lines here in this part?
End Sub
Yes that is what you need to do.
Private Sub IncDec(textbox As msforms.textbox, Increment As Boolean)
Dim iItem As Long
iItem = Evaluate("Match(" & textbox.Text & ", A1:A10, 0)")
If iItem 0 Then
If Increment Then
Cells(iItem, "B").Value = Cells(iItem, "B").Value + 1
Else
Cells(iItem, "B").Value = Cells(iItem, "B").Value - 1
End If
End If
End Sub
****In this part would I do the following as an example?*****
iItem=Evaluate("Match(" &textbox1.Text & ", B3, 0)")
if iItem 0 Then
if Increment Then
Cells(iItem, "B4").Value = Cells(item, "B4").Value +1
Else
Cells(item, "B4").Value = Cells(item, "B4").Value -1
End If
End If
End Sub
No, not
iItem=Evaluate("Match(" &textbox1.Text & ", B3, 0)")
as that is only testing against on e cell, an d I thought you wanted to
check a range of values, so it should be
iItem=Evaluate("Match(" &textbox1.Text & ", B3,:B20 0)")
or wherever the numbers end. Otherwise you would just cjheck
If textbox.Text = Range("B3").Value Then
You might want to add the sheet in there as well
iItem=Evaluate("Match(" &textbox1.Text & ", Sheet1!B3,:B20 0)")
My 1001.01 is located in Cell B3 on the spreedsheet. And the amount
that I want to add to and subtract from is in Cell B4. So, when I type
in the number 1001.01 in the textbox on the userform, the number in
Cell B4 will increase.
What should happen if the number is 1001.02?
Here's another question:
If textbox1 through textbox7 are under the ADD column on the userform
and textbox8 through 14 are under the SUBTRACT column, how would that
be written above? would it be like the following?
partial example
Private Sub IncDec(textbox As msforms.textbox, Increment As Boolean)
Dim iItem As Long
iItem = Evaluate("Match(" & textbox1.Text & ", B3, 0)")
If iItem 0 Then
If Increment Then
Cells(iItem, "B4").Value = Cells(iItem, "B4").Value + 1
Else
Cells(iItem, "B4").Value = Cells(iItem, "B4").Value - 1
End If
End If
iItem = Evaluate(Match(" & textbox1.Text & ", C3, 0)")
if iItem 0 Then
Cells(item, "C4").Value = Cells(iItem, " C4").Value +1
Else
Cells(iItem, "C4").Value = Cells(item, "C4").Value -1
End If
End If
End Sub
On my spreedsheet(classdb1) I have the following(small example):
1001.01 is in cell B3 and #amount(let's say 10) is in Cell B4.
1001.02 is in cell C3 and #amount(23) is in Cell C4
1001.03 is in cell D3 and #amount (8) is in Cell D4
No I assumed rows, it should be columns
Private Sub IncDec(textbox As msforms.textbox, Increment As Boolean)
Dim iItem As Long
iItem = Evaluate("Match(" & textbox.Text & ", B3, 0)")
If iItem 0 Then
If Increment Then
Cells(3,iItem+1).Value = Cells(3,iItem+1).Value + 1
Else
Cells(3,iItem+1).Value = Cells(3,iItem+1).Value - 1
End If
End If
End Sub
Bob, please post back and tell me if this is correct or not and if you
can, correct the example and then I'll start typing it up. I'm
thinking that this is going to get big.
Thank you,
marty6
---
Message posted from http://www.ExcelForum.com/