Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default How do I fill a cell in a user form from a selection on same form?

I'm new to creating user forms and I am working with a combo box sample form
I download from www.contextures.com (a great site I must add). I would like
to have data displayed on the same form once a user makes a selection from
the combo box. I.e. If the user selects account number '10-1000,' I would
like the description of this account, 'Petty-Cash' to display in the
adjoining field. This would just be a double check to make sure the desired
account was truly selected before adding data to my table. I'm sure I need a
look-up function, but I'm not sure how to tie the two together on the form.

Any help will be appreciated.

Thanks in advance.
--
T Tipsy
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How do I fill a cell in a user form from a selection on same form?

I'd create a new worksheet (and hide it???).

Put all those numeric codes in column A and the English description in column B.

Then in the combobox_change event, I'd use something like this to update a label
with the associated description:

Option Explicit
Private Sub ComboBox1_Change()

Dim myRng As Range
Dim res As Variant
If Me.ComboBox1.ListIndex < 0 Then
Exit Sub
End If

Set myRng = ThisWorkbook.Worksheets("myTable").Range("a:b")

res = Application.VLookup(Me.ComboBox1.Value, myRng, 2, False)

If IsError(res) Then
Me.Label1.Caption = "Missing!"
Else
Me.Label1.Caption = res
End If

End Sub
Private Sub UserForm_Initialize()

Dim iCtr As Long

Me.ComboBox1.Style = fmStyleDropDownList
Me.Label1.Caption = ""

'just some test data
With Me.ComboBox1
For iCtr = 0 To 6
Me.ComboBox1.AddItem "10-10" & iCtr
Next iCtr
End With

End Sub


Terry Tipsy wrote:

I'm new to creating user forms and I am working with a combo box sample form
I download from www.contextures.com (a great site I must add). I would like
to have data displayed on the same form once a user makes a selection from
the combo box. I.e. If the user selects account number '10-1000,' I would
like the description of this account, 'Petty-Cash' to display in the
adjoining field. This would just be a double check to make sure the desired
account was truly selected before adding data to my table. I'm sure I need a
look-up function, but I'm not sure how to tie the two together on the form.

Any help will be appreciated.

Thanks in advance.
--
T Tipsy


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default How do I fill a cell in a user form from a selection on same f

Dave - Thanks for the information and code. If I understand it correctly, I
could also use the same 'named' range I used to create the combo box, rather
than creating a new sheet?
--
T Tipsy


"Dave Peterson" wrote:

I'd create a new worksheet (and hide it???).

Put all those numeric codes in column A and the English description in column B.

Then in the combobox_change event, I'd use something like this to update a label
with the associated description:

Option Explicit
Private Sub ComboBox1_Change()

Dim myRng As Range
Dim res As Variant
If Me.ComboBox1.ListIndex < 0 Then
Exit Sub
End If

Set myRng = ThisWorkbook.Worksheets("myTable").Range("a:b")

res = Application.VLookup(Me.ComboBox1.Value, myRng, 2, False)

If IsError(res) Then
Me.Label1.Caption = "Missing!"
Else
Me.Label1.Caption = res
End If

End Sub
Private Sub UserForm_Initialize()

Dim iCtr As Long

Me.ComboBox1.Style = fmStyleDropDownList
Me.Label1.Caption = ""

'just some test data
With Me.ComboBox1
For iCtr = 0 To 6
Me.ComboBox1.AddItem "10-10" & iCtr
Next iCtr
End With

End Sub


Terry Tipsy wrote:

I'm new to creating user forms and I am working with a combo box sample form
I download from www.contextures.com (a great site I must add). I would like
to have data displayed on the same form once a user makes a selection from
the combo box. I.e. If the user selects account number '10-1000,' I would
like the description of this account, 'Petty-Cash' to display in the
adjoining field. This would just be a double check to make sure the desired
account was truly selected before adding data to my table. I'm sure I need a
look-up function, but I'm not sure how to tie the two together on the form.

Any help will be appreciated.

Thanks in advance.
--
T Tipsy


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How do I fill a cell in a user form from a selection on same f

Sure.

I just figured that there might be duplicates in the original data and you
wouldn't want those duplicates to show up in the dropdown.

Terry Tipsy wrote:

Dave - Thanks for the information and code. If I understand it correctly, I
could also use the same 'named' range I used to create the combo box, rather
than creating a new sheet?
--
T Tipsy

"Dave Peterson" wrote:

I'd create a new worksheet (and hide it???).

Put all those numeric codes in column A and the English description in column B.

Then in the combobox_change event, I'd use something like this to update a label
with the associated description:

Option Explicit
Private Sub ComboBox1_Change()

Dim myRng As Range
Dim res As Variant
If Me.ComboBox1.ListIndex < 0 Then
Exit Sub
End If

Set myRng = ThisWorkbook.Worksheets("myTable").Range("a:b")

res = Application.VLookup(Me.ComboBox1.Value, myRng, 2, False)

If IsError(res) Then
Me.Label1.Caption = "Missing!"
Else
Me.Label1.Caption = res
End If

End Sub
Private Sub UserForm_Initialize()

Dim iCtr As Long

Me.ComboBox1.Style = fmStyleDropDownList
Me.Label1.Caption = ""

'just some test data
With Me.ComboBox1
For iCtr = 0 To 6
Me.ComboBox1.AddItem "10-10" & iCtr
Next iCtr
End With

End Sub


Terry Tipsy wrote:

I'm new to creating user forms and I am working with a combo box sample form
I download from www.contextures.com (a great site I must add). I would like
to have data displayed on the same form once a user makes a selection from
the combo box. I.e. If the user selects account number '10-1000,' I would
like the description of this account, 'Petty-Cash' to display in the
adjoining field. This would just be a double check to make sure the desired
account was truly selected before adding data to my table. I'm sure I need a
look-up function, but I'm not sure how to tie the two together on the form.

Any help will be appreciated.

Thanks in advance.
--
T Tipsy


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default How do I fill a cell in a user form from a selection on same f

Dave - Thanks again. It may be a few days before I can get back to this
project. I may post back again if I run into difficulties or have more
questions.
--
T Tipsy


"Dave Peterson" wrote:

Sure.

I just figured that there might be duplicates in the original data and you
wouldn't want those duplicates to show up in the dropdown.

Terry Tipsy wrote:

Dave - Thanks for the information and code. If I understand it correctly, I
could also use the same 'named' range I used to create the combo box, rather
than creating a new sheet?
--
T Tipsy

"Dave Peterson" wrote:

I'd create a new worksheet (and hide it???).

Put all those numeric codes in column A and the English description in column B.

Then in the combobox_change event, I'd use something like this to update a label
with the associated description:

Option Explicit
Private Sub ComboBox1_Change()

Dim myRng As Range
Dim res As Variant
If Me.ComboBox1.ListIndex < 0 Then
Exit Sub
End If

Set myRng = ThisWorkbook.Worksheets("myTable").Range("a:b")

res = Application.VLookup(Me.ComboBox1.Value, myRng, 2, False)

If IsError(res) Then
Me.Label1.Caption = "Missing!"
Else
Me.Label1.Caption = res
End If

End Sub
Private Sub UserForm_Initialize()

Dim iCtr As Long

Me.ComboBox1.Style = fmStyleDropDownList
Me.Label1.Caption = ""

'just some test data
With Me.ComboBox1
For iCtr = 0 To 6
Me.ComboBox1.AddItem "10-10" & iCtr
Next iCtr
End With

End Sub


Terry Tipsy wrote:

I'm new to creating user forms and I am working with a combo box sample form
I download from www.contextures.com (a great site I must add). I would like
to have data displayed on the same form once a user makes a selection from
the combo box. I.e. If the user selects account number '10-1000,' I would
like the description of this account, 'Petty-Cash' to display in the
adjoining field. This would just be a double check to make sure the desired
account was truly selected before adding data to my table. I'm sure I need a
look-up function, but I'm not sure how to tie the two together on the form.

Any help will be appreciated.

Thanks in advance.
--
T Tipsy

--

Dave Peterson


--

Dave Peterson

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
Display contents of a cell in a user form text box -- Excel 2003 VBA hiskilini Excel Discussion (Misc queries) 7 April 4th 23 10:22 AM
How do i fill the adjacent cell formulas in user form when i press Vicky Excel Discussion (Misc queries) 0 June 5th 06 07:38 AM
how to get a data form to fill you own exel sheet (was data-form erik van buijtenen Excel Worksheet Functions 2 May 30th 06 05:31 PM
make a cell required to fill-in on form template Jo Excel Worksheet Functions 0 December 1st 05 07:01 PM
Allow user to fill in on-line form without changing formatting agnita Excel Worksheet Functions 0 October 24th 05 05:01 PM


All times are GMT +1. The time now is 11:28 PM.

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"