ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Inputbox with Listbox (https://www.excelbanter.com/excel-discussion-misc-queries/2404-inputbox-listbox.html)

Jeff

Inputbox with Listbox
 
Hello,

I have a listbox of names with a row.source. I'd like, if possible, to
create a VBA macro that would, after clicking on a name, trigger an inputbox
that would enable me to add a $ value in the corresponding row (of the name
clicked) in Column E.
Jeff


Nick Hodge

Jeff

Made a few presumptions.

1) It's an activeX listbox on the worksheet (called ListBox1)
2) The 'listrange' (filling the list box' is in Range("A1:A11"))
3) This is only rough code. No error checking etc.
4) I am using the 'click' event of the control

Private Sub ListBox1_Click()
Dim sName As String
Dim dVal As Double
sName = ListBox1.Value
dVal = Application.InputBox("Enter a value for " & sName, , , , , , , 1)
Range("A1:A11").Find(sName).Offset(0, 1).Value = dVal
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"Jeff" wrote in message
...
Hello,

I have a listbox of names with a row.source. I'd like, if possible, to
create a VBA macro that would, after clicking on a name, trigger an
inputbox
that would enable me to add a $ value in the corresponding row (of the
name
clicked) in Column E.
Jeff




Jeff

Thank you Nick,
This is what I needed.
Could you please tell what should I do to make sure "dval" is added and does
not overwrite if there already a value the row ?
Thanks,
JF


"Nick Hodge" wrote:

Jeff

Made a few presumptions.

1) It's an activeX listbox on the worksheet (called ListBox1)
2) The 'listrange' (filling the list box' is in Range("A1:A11"))
3) This is only rough code. No error checking etc.
4) I am using the 'click' event of the control

Private Sub ListBox1_Click()
Dim sName As String
Dim dVal As Double
sName = ListBox1.Value
dVal = Application.InputBox("Enter a value for " & sName, , , , , , , 1)
Range("A1:A11").Find(sName).Offset(0, 1).Value = dVal
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"Jeff" wrote in message
...
Hello,

I have a listbox of names with a row.source. I'd like, if possible, to
create a VBA macro that would, after clicking on a name, trigger an
inputbox
that would enable me to add a $ value in the corresponding row (of the
name
clicked) in Column E.
Jeff





Nick Hodge

Jeff

Private Sub ListBox1_Click()
Dim sName As String
Dim dVal As Double
sName = ListBox1.Value
dVal = Application.InputBox("Enter a value for " & sName, , , , , , , 1)
Range("A1:A11").Find(sName).Offset(0, 1).Value = _
Range("A1:A11").Find(sName).Offset(0, 1).Value + dVal
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"Jeff" wrote in message
...
Thank you Nick,
This is what I needed.
Could you please tell what should I do to make sure "dval" is added and
does
not overwrite if there already a value the row ?
Thanks,
JF


"Nick Hodge" wrote:

Jeff

Made a few presumptions.

1) It's an activeX listbox on the worksheet (called ListBox1)
2) The 'listrange' (filling the list box' is in Range("A1:A11"))
3) This is only rough code. No error checking etc.
4) I am using the 'click' event of the control

Private Sub ListBox1_Click()
Dim sName As String
Dim dVal As Double
sName = ListBox1.Value
dVal = Application.InputBox("Enter a value for " & sName, , , , , , , 1)
Range("A1:A11").Find(sName).Offset(0, 1).Value = dVal
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"Jeff" wrote in message
...
Hello,

I have a listbox of names with a row.source. I'd like, if possible, to
create a VBA macro that would, after clicking on a name, trigger an
inputbox
that would enable me to add a $ value in the corresponding row (of the
name
clicked) in Column E.
Jeff








All times are GMT +1. The time now is 09:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com