Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Listbox value help needed

I have what I think is going to be an easy (easier anyway) question. I
have an excel spreadsheet with about 1000 rows of data with 3 columns.
I have a userform setup with a combo box. What I would like to see, is
when a value from the combo box is entered (from column A) I would like
that value of a text box to show the item found in Column B of the same
row. So if the value is from A600, then the value in the textbox is
from B600.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Listbox value help needed

you can give this a try. it's a userform with 1 combobox and 2 textboxes.
when you enter or choose a value from the combobox, the values from that row in
columns B and C are entered into the 2 textboxes
if you don't want to fire on change, but when the combobox is exited, then use:
Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
as the first line instead.

Private Sub ComboBox1_Change()
Dim ws As Worksheet
Dim lastrow As Long, frow As Long, rng As Range, rngfound As Range
Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
frow = ws.Range("A1").Row
Set rng = ws.Range("A" & frow & ":A" & lastrow)
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

With rng
On Error Resume Next
Set rngfound = .Find(What:=Me.ComboBox1.Value, LookIn:=xlValues, _
LookAt:=xlWhole)
If Not rngfound Is Nothing Then
With Me
.TextBox1.Value = Range("B" & rngfound.Row)
.TextBox2.Value = Range("C" & rngfound.Row)
End With
Else
MsgBox "Item number not found."
Me.ComboBox1.Value = ""
Exit Sub
End If
End With

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub

--


Gary


wrote in message
ups.com...
I have what I think is going to be an easy (easier anyway) question. I
have an excel spreadsheet with about 1000 rows of data with 3 columns.
I have a userform setup with a combo box. What I would like to see, is
when a value from the combo box is entered (from column A) I would like
that value of a text box to show the item found in Column B of the same
row. So if the value is from A600, then the value in the textbox is
from B600.



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
short cut needed for listbox(sorry a bit long) Baha Excel Programming 0 November 10th 06 12:18 PM
userform listbox cannot get listbox.value to transfer back to main sub [email protected] Excel Programming 1 May 17th 06 09:44 PM
VBA: Creating listbox similar to the one in Pivot table (Listbox+Checkbox) modjoe23 Excel Programming 3 August 18th 05 02:35 PM
Soup to nuts listbox help needed Jim[_55_] Excel Programming 2 January 26th 05 04:24 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM


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