Help with userform?

G

Greg B

I have a userform with a listbox and a couple of textbox's

I want to have a macro that will lookup the name in the listbox on a sheet
called "reg" and have textbox1 add its amount to the amount in column e and
textbox2 add its total to column f on the same row.

Thanks

Greg
 
B

Bob Phillips

Dim iPos as long

Set rng = worksheets("Sheet1").Range("A1:A10")
On Error Resume Next
iPos = Application.Vlookup(Listbox1.Value,
On Error Goto 0
If iPos > 0 Then
worksheets("Sheet1").Cells(iPos,"E").Value = _
worksheets("Sheet1").Cells(iPos,"E").Value + Textbox1.Text
worksheets("Sheet1").Cells(iPos,"F").Value = _
worksheets("Sheet1").Cells(iPos,"F").Value + Textbox2.Text
End If

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
G

Greg B

Thanks for that will give it a go

Greg
Bob Phillips said:
Dim iPos as long

Set rng = worksheets("Sheet1").Range("A1:A10")
On Error Resume Next
iPos = Application.Vlookup(Listbox1.Value,
On Error Goto 0
If iPos > 0 Then
worksheets("Sheet1").Cells(iPos,"E").Value = _
worksheets("Sheet1").Cells(iPos,"E").Value + Textbox1.Text
worksheets("Sheet1").Cells(iPos,"F").Value = _
worksheets("Sheet1").Cells(iPos,"F").Value + Textbox2.Text
End If

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top