Userform - with Commandbutton fill a Listbox with data..

A

Arjan

Hi all,

I would like to ask your help for my challange :)

Scope:
I have 15 sheets, on every sheet there are 3 colunms (A, B and C) filled
with data..(the number of rows do differ)

Question:
On a 'Userform' I have made 15 commandbuttons and 1 'Listbox' without input
field..

This is what I would like to do:
When CommandButton1 is clicked, I want the data (from page 1) to be shown in
the Listbox..
etc. so..

When commandbutton2 is clicked, I want the data (from page 2) to be shown in
the Listbox..
When commandbutton3 is clicked, I want the data (from page 3) to be shown in
the Listbox..
...
When CommandButton15 is clicked, I want the data (from page 15) to be shown
in the Listbox..

How can I do this with VBA? are there expamples? So I can see how I can do
it?

thnx! for your help..

Arjan
the Netherlands
 
T

Tom Ogilvy

Private Sub CommandButton1_Click()
Dim rng as Range
With Worksheets("Sheet1")
set rng = .Range("A1").Currentregion.Resize(,3)
' if you don't want the first row uncomment the next line
' set rng = rng.offset(1,0).Resize(rng.rows.count-1,3)
End With
ListBox1.ColumnCount = 3
ListBox1.List = rng.value
End With


Repeat for each button.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top