View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Help with vba coding/userform....

Marty,

The idea is right, but I think you need this code

Private Sub IncDec(textbox As msforms.textbox, Increment As Boolean)
Dim iItem As Long
On Error Resume Next
iItem = Evaluate("Match(" & textbox.Text & ",A1:H1, 0)")
If iItem Then
If Increment Then
Cells(2, iItem).Value = Cells(2, iItem).Value + 1
Else
Cells(2, iItem).Value = Cells(2, iItem).Value - 1
End If
Else
iItem = Evaluate("Match(" & textbox.Text & ",A3:H3, 0)")
If iItem Then
If Increment Then
Cells(4, iItem).Value = Cells(4, iItem).Value + 1
Else
Cells(4, iItem).Value = Cells(4, iItem).Value - 1
End If
End If
End If
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"marty6 " wrote in message
...
Bob,

Is there a way to have a third and fourth line added for sequencing?

a1:h1 are the section numbers
a2:h2 are product numbers

Can I add a3:h3 as more product numbers and added a4:h4 as more product
numbers and keep the same setup in the userform but add these lines?


Private Sub IncDec(textbox As msforms.textbox, Increment As Boolean)
Dim iItem As Long

Would it be something like this?


On Error GoTo incdec_exit
iItem = Evaluate("Match(" & textbox.Text & ",A1:H1, 0)")
If iItem Then
If Increment Then
Cells(2, iItem).Value = Cells(2, iItem).Value + 1
Else
Cells(2, iItem).Value = Cells(2, iItem).Value - 1
End If
End If
iItem = Evaluate("Match(" & textbox.Text & ",A3:H3, 0)")
If iItem Then
If Increment Then
Cells(4, iItem).Value = Cells(4, iItem).Value + 1
Else
Cells(4, iItem).Value = Cells(4, iItem).Value - 1
end if
end if
incdec_exit:
End Sub

Thank you again for your advice! It worked great!!:) :)

marty6

I tried this and had an error with the line:
iItem = Evaluate("Match(" & textbox.Text & ",A3:H3, 0)")
Your thoughts?

Thank you again....marty6


---
Message posted from http://www.ExcelForum.com/