Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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
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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
stubborn Excel crash when editing code with code, one solution Brian Murphy Excel Programming 0 February 20th 05 05:56 AM
VBA code delete code but ask for password and unlock VBA protection WashoeJeff Excel Programming 0 January 27th 04 07:07 AM


All times are GMT +1. The time now is 06:25 AM.

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

About Us

"It's about Microsoft Excel"