PC Review


Reply
Thread Tools Rate Thread

How do I get a list from an excel sheet into a userform/listbox?

 
 
=?iso-8859-1?q?=D6rjan_Kihlbaum?=
Guest
Posts: n/a
 
      31st Oct 2007
Hello all,

I am very new to the VBA programming language. I have managed to solve
most of my problems by looking for answers here, on the Internet and
in a nice little book called "Excel 2003 VBA".

Background:
I am planning to have a excel sheet that can display information based
on a list located in another sheet (a database of sorts). So, the
"database sheet" contains names,numbers and values and I plan to have
a "display sheet" that will display values and calculations for one
member of the database/list at a time.

VBA involvment:
I want to be able to press a button to open up a simple userform with
a listbox.
In the listbox I want to list the members of the database.
When I click on any of the members I want the userform to close and
that the values for that perticular member to be displayed in my
"display sheet".

Problem:
Well, the excel part is easy enough but I really don't know where to
start with the VBA.
I have created a userfrom and I have added a listbox.

Now how do I get the listbox to display the "members" from the
database sheet?

All the rest I'll worry about later..


I haven't found any article yet to help me so maybe anyone here knows
where I should start to look for info?
Or can you give a hint so I know where to start?

 
Reply With Quote
 
 
 
 
gwoodby@gmail.com
Guest
Posts: n/a
 
      31st Oct 2007
On Oct 31, 9:02 am, Örjan Kihlbaum <Kihlb...@gmail.com> wrote:
> Hello all,
>
> I am very new to the VBA programming language. I have managed to solve
> most of my problems by looking for answers here, on the Internet and
> in a nice little book called "Excel 2003 VBA".
>
> Background:
> I am planning to have a excel sheet that can display information based
> on a list located in another sheet (a database of sorts). So, the
> "database sheet" contains names,numbers and values and I plan to have
> a "display sheet" that will display values and calculations for one
> member of the database/list at a time.
>
> VBA involvment:
> I want to be able to press a button to open up a simple userform with
> a listbox.
> In the listbox I want to list the members of the database.
> When I click on any of the members I want the userform to close and
> that the values for that perticular member to be displayed in my
> "display sheet".
>
> Problem:
> Well, the excel part is easy enough but I really don't know where to
> start with the VBA.
> I have created a userfrom and I have added a listbox.
>
> Now how do I get the listbox to display the "members" from the
> database sheet?
>
> All the rest I'll worry about later..
>
> I haven't found any article yet to help me so maybe anyone here knows
> where I should start to look for info?
> Or can you give a hint so I know where to start?


Wouldnt it be easier to just add a find button, and a textbox to
input the name they are looking for ?
Private Sub CommandButton1_Click()
Dim rng As Range
Dim ws As Worksheet
Dim SearchTxt As String
Dim Row As Integer
Dim firstAddress As String
Set ws = Worksheets("sheet1")
SearchTxt = TextBox1.Text ' This is textbox they are
putting the name into


If TextBox1.Text= "" Then
GoTo ErrorMessage
End If
Set rng = ws.Cells.Find(What:=SearchTxt, After:=ws.Range("A1"), _
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If Not r Is Nothing Then
firstAddress = r.Address
Do
Set rng = Cells.FindNext(rng)
Listbox.AddItem (rng)
Loop While Not rng Is Nothing And rng.Address <> firstAddress
Else
' What you want it to do if thats false
End if

ErrorMessage:
MsgBox "Please Type a Name", vbInformation, " No Names found"
End Sub

 
Reply With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      31st Oct 2007
You can use RowSource, AddItem or List methods to load the ListBox or ComboBox.
Open the VBA editor (Alt + F11) and click help, then type one of the above
methods into the search box to display a menu of related articles.
"Ă–rjan Kihlbaum" wrote:

> Hello all,
>
> I am very new to the VBA programming language. I have managed to solve
> most of my problems by looking for answers here, on the Internet and
> in a nice little book called "Excel 2003 VBA".
>
> Background:
> I am planning to have a excel sheet that can display information based
> on a list located in another sheet (a database of sorts). So, the
> "database sheet" contains names,numbers and values and I plan to have
> a "display sheet" that will display values and calculations for one
> member of the database/list at a time.
>
> VBA involvment:
> I want to be able to press a button to open up a simple userform with
> a listbox.
> In the listbox I want to list the members of the database.
> When I click on any of the members I want the userform to close and
> that the values for that perticular member to be displayed in my
> "display sheet".
>
> Problem:
> Well, the excel part is easy enough but I really don't know where to
> start with the VBA.
> I have created a userfrom and I have added a listbox.
>
> Now how do I get the listbox to display the "members" from the
> database sheet?
>
> All the rest I'll worry about later..
>
>
> I haven't found any article yet to help me so maybe anyone here knows
> where I should start to look for info?
> Or can you give a hint so I know where to start?
>
>

 
Reply With Quote
 
=?iso-8859-1?q?=D6rjan_Kihlbaum?=
Guest
Posts: n/a
 
      31st Oct 2007
On Oct 31, 3:22 pm, gwoo...@gmail.com wrote:
> On Oct 31, 9:02 am, Örjan Kihlbaum <Kihlb...@gmail.com> wrote:
>
>
>
>
>
> > Hello all,

>
> > I am very new to the VBA programming language. I have managed to solve
> > most of my problems by looking for answers here, on the Internet and
> > in a nice little book called "Excel 2003 VBA".

>
> > Background:
> > I am planning to have a excel sheet that can display information based
> > on a list located in another sheet (a database of sorts). So, the
> > "database sheet" contains names,numbers and values and I plan to have
> > a "display sheet" that will display values and calculations for one
> > member of the database/list at a time.

>
> > VBA involvment:
> > I want to be able to press a button to open up a simple userform with
> > a listbox.
> > In the listbox I want to list the members of the database.
> > When I click on any of the members I want the userform to close and
> > that the values for that perticular member to be displayed in my
> > "display sheet".

>
> > Problem:
> > Well, the excel part is easy enough but I really don't know where to
> > start with the VBA.
> > I have created a userfrom and I have added a listbox.

>
> > Now how do I get the listbox to display the "members" from the
> > database sheet?

>
> > All the rest I'll worry about later..

>
> > I haven't found any article yet to help me so maybe anyone here knows
> > where I should start to look for info?
> > Or can you give a hint so I know where to start?

>
> Wouldnt it be easier to just add a find button, and a textbox to
> input the name they are looking for ?
> Private Sub CommandButton1_Click()
> Dim rng As Range
> Dim ws As Worksheet
> Dim SearchTxt As String
> Dim Row As Integer
> Dim firstAddress As String
> Set ws = Worksheets("sheet1")
> SearchTxt = TextBox1.Text ' This is textbox they are
> putting the name into
>
> If TextBox1.Text= "" Then
> GoTo ErrorMessage
> End If
> Set rng = ws.Cells.Find(What:=SearchTxt, After:=ws.Range("A1"), _
> LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
> SearchDirection:=xlNext, MatchCase:=False)
> If Not r Is Nothing Then
> firstAddress = r.Address
> Do
> Set rng = Cells.FindNext(rng)
> Listbox.AddItem (rng)
> Loop While Not rng Is Nothing And rng.Address <> firstAddress
> Else
> ' What you want it to do if thats false
> End if
>
> ErrorMessage:
> MsgBox "Please Type a Name", vbInformation, " No Names found"
> End Sub- Hide quoted text -
>
> - Show quoted text -


Nope, sorry. It needs to be supersimple. Having to type in the names
wont do unfortunally.

Thanks though!

 
Reply With Quote
 
=?iso-8859-1?q?=D6rjan_Kihlbaum?=
Guest
Posts: n/a
 
      31st Oct 2007
On Oct 31, 3:26 pm, JLGWhiz <JLGW...@discussions.microsoft.com> wrote:
> You can use RowSource, AddItem or List methods to load the ListBox or ComboBox.
> Open the VBA editor (Alt + F11) and click help, then type one of the above
> methods into the search box to display a menu of related articles.
>
>
>
> "Örjan Kihlbaum" wrote:
> > Hello all,

>
> > I am very new to the VBA programming language. I have managed to solve
> > most of my problems by looking for answers here, on the Internet and
> > in a nice little book called "Excel 2003 VBA".

>
> > Background:
> > I am planning to have a excel sheet that can display information based
> > on a list located in another sheet (a database of sorts). So, the
> > "database sheet" contains names,numbers and values and I plan to have
> > a "display sheet" that will display values and calculations for one
> > member of the database/list at a time.

>
> > VBA involvment:
> > I want to be able to press a button to open up a simple userform with
> > a listbox.
> > In the listbox I want to list the members of the database.
> > When I click on any of the members I want the userform to close and
> > that the values for that perticular member to be displayed in my
> > "display sheet".

>
> > Problem:
> > Well, the excel part is easy enough but I really don't know where to
> > start with the VBA.
> > I have created a userfrom and I have added a listbox.

>
> > Now how do I get the listbox to display the "members" from the
> > database sheet?

>
> > All the rest I'll worry about later..

>
> > I haven't found any article yet to help me so maybe anyone here knows
> > where I should start to look for info?
> > Or can you give a hint so I know where to start?- Hide quoted text -

>
> - Show quoted text -


Thank you!

I'll dive into this right away!

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
From ListBox selection >labels on userform to show sheet cell valu ProPolyglot Microsoft Excel Programming 0 22nd Apr 2010 12:36 PM
Excel 2003 - VBA - Listbox on userform C Brandt Microsoft Excel Misc 2 23rd Dec 2007 05:15 AM
Listbox on Excel Userform jeff.white@amcore.com Microsoft Excel Programming 5 16th Jul 2007 03:30 PM
Userform Listbox using an active sheet steve.sparti@gmail.com Microsoft Excel Misc 0 1st Mar 2006 08:22 PM
excel vba userform listbox Microsoft Outlook VBA Programming 1 27th Jan 2004 03:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:22 PM.