LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Need help with userform....please....



"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/



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UserForm bgkgmg Excel Worksheet Functions 1 February 26th 09 04:25 PM
UserForm FSt1 Excel Worksheet Functions 0 February 26th 09 02:00 AM
Userform Jeff Excel Discussion (Misc queries) 0 February 6th 06 09:30 PM
UserForm 2 Tim Excel Programming 3 February 13th 04 12:12 PM
UserForm John Beaumont Excel Programming 1 December 19th 03 04:41 PM


All times are GMT +1. The time now is 05:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"