Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Jeff
 
Posts: n/a
Default 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

  #2   Report Post  
Nick Hodge
 
Posts: n/a
Default

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



  #3   Report Post  
Jeff
 
Posts: n/a
Default

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




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
Listbox in VBA Jeff Excel Discussion (Misc queries) 1 December 16th 04 01:48 AM
ListBox (maybe?) ... If so, how? Ken Excel Discussion (Misc queries) 3 December 15th 04 10:16 PM


All times are GMT +1. The time now is 07:10 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"