Selecting & copying a named range through a listbox

L

Luc

When i click on a button i want a listbox to pop up.
In this listbox there has to appear a list with named ranges.
The named range which is selected in this listbox has to be copied

Can somenone give me some code for this.

That's it !

Thanxxx,

Luc
 
R

Ryan H

Since your post is kinda vague I will have to ask some questions and makes
some assumptions.

1.) Are you wanting to select multiple ranges to be copied from a listbox
or select a single range to be copied from a combobox?

2.) Where do you want the range copied to? Another worksheet, workbook,
somewhere else within the sheet?

3.) Are you wanting to copy values only or all formats?

This can get you started. Start a userform and put a combobox and command
button in it. Then put this code in the userform module. When you call the
userform the combobox will be filled with all the names in your workbook.
Select the name you want to copy then click the command button. Once you
click the command button it will copy that range to Sheet2 starting in A1.
Hope this helps! If so, let me know, click "YES" below.

Option Explicit

Private Sub UserForm_Initialize()

Dim n As Name

' add range names to combobox
With Me.ComboBox1
For Each n In Names
.AddItem n.Name
Next n
End With

End Sub

Private Sub CommandButton1_Click()

' copy selected named range to sheet2 starting at A1
Range(Me.ComboBox1.Text).Copy Sheets("Sheet2").Range("A1")

End Sub
 

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