Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default selectively copying ranges from one sheet to second sheet

First time user

I have a sheet with multiple range names (range1, range2, range3, etc). I would like to have a list box with the range names in that list. If the user selects range2, then that range is the one that I would like to copy to a predetermined range on sheet 2. The range sizes are the same. Also, if they make a mistake, and select the wrong range, I would like for them to be able to reselect the appropriate range. I can get this to work with a macro where I enter the "from" range. I would like to automate that with the list box or something like that. Anything with the names already predefined so user can't enter an incorrect range name.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default selectively copying ranges from one sheet to second sheet

JPTIII

First you need a sub that fills the listbox, like this

Sub PopLb()

Dim nm As Name

For Each nm In Sheet1.Parent.Names
Sheet1.ListBox1.AddItem nm.Name
Next nm

End Sub

Then you need to use the Click event of the listbox, like this

Private Sub ListBox1_Click()

Me.Range(Me.ListBox1.Value).Copy Sheet2.Range("a1")

End Sub

To get to the click event, select the listbox and choose View Code from the
right click menu. Use the dropdowns to select the Click event.

For the first sub, you have to decide when you want to run. For instance,
you can run it every time the workbook opens by using the Workbook_Open
event. Or if the range names won't ever change, you can just run it once
and be done with it.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"JPTIII" wrote in message
...
First time user.

I have a sheet with multiple range names (range1, range2, range3, etc). I

would like to have a list box with the range names in that list. If the
user selects range2, then that range is the one that I would like to copy to
a predetermined range on sheet 2. The range sizes are the same. Also, if
they make a mistake, and select the wrong range, I would like for them to be
able to reselect the appropriate range. I can get this to work with a macro
where I enter the "from" range. I would like to automate that with the list
box or something like that. Anything with the names already predefined so
user can't enter an incorrect range name.


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
Need help Taking alot data from one sheet (if not blank) and copying toa list on another sheet. Alex Zuniga Excel Worksheet Functions 1 November 25th 09 11:54 PM
Copying the repeated data of the previous sheet to the next sheet Sasikiran Excel Discussion (Misc queries) 1 September 25th 07 03:18 PM
help with copying multiple ranges and paste it on a work sheet based on conditions prakash Excel Discussion (Misc queries) 0 November 30th 06 10:18 AM
Dynamic column chart - copying from Sheet to Sheet. Marko Pinteric Excel Discussion (Misc queries) 1 April 10th 06 12:57 PM
2 questions, copying data from sheet to sheet and assigning macro Boris Excel Worksheet Functions 0 December 16th 04 06:11 PM


All times are GMT +1. The time now is 07:55 AM.

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"