Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with code please
I am looking for help with a macro.
I have a userform where I use combobox1 to select the person I need. I need the macro to lookup the matching value in combobox1 to the value selected from column A. then using code, I wish to add the value of textbox1 to the value of the cell in column b and have the total of the two be laced in that cell. for example i have combobox1 value = greg textbox1 = 5 column a column b greg 3 I would like for column b to change to 8 How would I do that? Thanks Greg |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with code please
Hello Greg,
Give this code a shot, and see if it does what your looking for. I run this example code from a UserForm using a CommandButton1, ComboBox1, TextBox1. If you have any questions, feel free to ask. Enjoy, Rick Option Explicit Private Sub CommandButton1_Click() Dim ws1 As Worksheet Dim r As Integer Set ws1 = Worksheets("Sheet1") r = 3 '' start row '' Find Name in Column "A" Sheet1 Do Until IsEmpty(ws1.Cells(r, "A")) If Me.ComboBox1 = ws1.Cells(r, "A") Then ws1.Cells(r, "B") = ws1.Cells(r, "B") + CInt(Me.TextBox1) Exit Sub '' name found, let exit sub End If r = r + 1 '' next row Loop End Sub "Greg B" wrote in message ... I am looking for help with a macro. I have a userform where I use combobox1 to select the person I need. I need the macro to lookup the matching value in combobox1 to the value selected from column A. then using code, I wish to add the value of textbox1 to the value of the cell in column b and have the total of the two be laced in that cell. for example i have combobox1 value = greg textbox1 = 5 column a column b greg 3 I would like for column b to change to 8 How would I do that? Thanks Greg |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with code please
Is the combobox sourced from Column A? If so, why not use the Listindex
property With Range("B" & Combobox1.Listindex) .Value = .Value + CDbl(Textbox1.Text) End With -- HTH Bob Phillips (remove nothere from the email address if mailing direct) "Greg B" wrote in message ... I am looking for help with a macro. I have a userform where I use combobox1 to select the person I need. I need the macro to lookup the matching value in combobox1 to the value selected from column A. then using code, I wish to add the value of textbox1 to the value of the cell in column b and have the total of the two be laced in that cell. for example i have combobox1 value = greg textbox1 = 5 column a column b greg 3 I would like for column b to change to 8 How would I do that? Thanks Greg |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with code please
Thank you both for the help it works great.
Greg "Rick Hansen" wrote in message ... Hello Greg, Give this code a shot, and see if it does what your looking for. I run this example code from a UserForm using a CommandButton1, ComboBox1, TextBox1. If you have any questions, feel free to ask. Enjoy, Rick Option Explicit Private Sub CommandButton1_Click() Dim ws1 As Worksheet Dim r As Integer Set ws1 = Worksheets("Sheet1") r = 3 '' start row '' Find Name in Column "A" Sheet1 Do Until IsEmpty(ws1.Cells(r, "A")) If Me.ComboBox1 = ws1.Cells(r, "A") Then ws1.Cells(r, "B") = ws1.Cells(r, "B") + CInt(Me.TextBox1) Exit Sub '' name found, let exit sub End If r = r + 1 '' next row Loop End Sub "Greg B" wrote in message ... I am looking for help with a macro. I have a userform where I use combobox1 to select the person I need. I need the macro to lookup the matching value in combobox1 to the value selected from column A. then using code, I wish to add the value of textbox1 to the value of the cell in column b and have the total of the two be laced in that cell. for example i have combobox1 value = greg textbox1 = 5 column a column b greg 3 I would like for column b to change to 8 How would I do that? Thanks Greg |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Code to conditional format all black after date specified in code? | Excel Discussion (Misc queries) | |||
Drop Down/List w/Code and Definition, only code entered when selec | Excel Worksheet Functions | |||
stubborn Excel crash when editing code with code, one solution | Excel Programming | |||
VBA code delete code but ask for password and unlock VBA protection | Excel Programming |