View Single Post
  #2   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....

Hi Marty,

I thought we had got further than this last week.

This should complete it.

Private Sub CommandButton1_Click()
IncDec txt1Add, True
IncDec txt1Subtract, False
IncDec txt2Add, True
IncDec txt2Subtract, False
IncDec txt3Add, True
IncDec txt3Subtract, False
IncDec txt4Add, True
IncDec txt4Subtract, False
IncDec txt5Add, True
IncDec txt5Subtract, False
IncDec txt6Add, True
IncDec txt6Subtract, False
IncDec txt7Add, True
IncDec txt7Subtract, False
End Sub

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

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
incdec_exit:
End Sub

Private Sub CommandButton2_Click()
End
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
...
Hi guys,

Hate to post this again but I still need help on a vba userform.
Here's what I have so far thanks to Bob Phillips. :) I have modified
the programming that he is helping me with. This is what I have so
far:


Private Sub CommandButton1_Click()
IncDec txt1Add, True
IncDec txt1Subtract, true
End Sub

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

iItem = Evaluate("Match(" & txt1Add.Text & ",A1, 0)")
If iItem Then
If Increment Then
Cells(2, 1).Value = Cells(2, 1).Value + 1
End If
End If
End Sub

Private Sub CommandButton2_Click()
End
End Sub

Private Sub UserForm_Click()

End Sub

______________________________________________

Here's part of my layout on my spreed sheet:

A1 has 1001.01
B1 has 1001.02
C1 has 1001.03

A2 has 10
B2 has 10
C2 has 10

What I'm trying to do is create a userform with inputboxes that will
allow 1001.01(A1) to update 10(A2). The form has will have 7 boxes
under the word Add on the userform and 7 boxes under the word Subtract.
I would like to be able to input 1001.01 in any of the add boxes
inorder to update A2. And also be able to type in 1001.02 in any of
the Add boxes and update only B2. These ("1001.01") type of numbers
represent section numbers and the 10 numbers or any number in column
two will represent amounts. I could have all the section numbers in
column A and all the updatable quantity numbers in column B. Is there
a way in order to this to work? Is there a way of using Match item in
column A and update corresponding cell in column b by "1". If a
section number is enter in an inputbox on the userforum under the
subtract column, then the opposite effect would happen. The
corresponding cell would decrease.

With this part of the program I modified:
iItem = Evaluate("Match(" & txt1Add.Text & ",A1, 0)")
If iItem Then
If Increment Then
Cells(2, 1).Value = Cells(2, 1).Value + 1

When I put "1001.01" in the txt1Add input box, the Cell A2 gets updated
by 1.

I added the following, but got a debugging error:

iItem = Evaluate("Match(" & txt1subtract.text & ",A1, 0)")
If iItem Then
If Increment Then
Cells(2, 1).Value = Cells(2, 1).Value + 1

Is there a way to have it as such:

(for the add boxes)
List:
If 1001.01(A1) then add 1 to b1
If 1001.02(A2) then add 1 to b2
If 1001.03(A3) the add 1 to b3
ect...?

(for the subtract boxes)
List:
If 1001.01(A1) then subtract 1 from b1
etc....?

Any help is appreciated!

marty6


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