+ Reply to Thread
Results 1 to 8 of 8

Variable to select range to copy and paste to

  1. #1
    Registered User
    Join Date
    03-26-2004
    Posts
    4

    Variable to select range to copy and paste to

    Hello -- Looking for VBA code to read a variable (say, in cell A1), which corresponds to one of 30-40 range names on the same sheet, then copy that range and paste-special-values into another range on another sheet, also corresponding to that same variable. Any ideas? Thanks....

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    See how this goes

    Please Login or Register  to view this content.
    I couldn't be sure if the ranges were the same size, so I've assumed that the range name on the data sheet was multiple cell, while the range name on the output sheet was a single cell.


    rylo

  3. #3
    Registered User
    Join Date
    03-26-2004
    Posts
    4

    I was not clear...

    Rylo -- Thanks for responding. I need to describe in more detail...

    My program brings a few 1000 lines of data into columns a-e of a spreadsheet (say, sheet 1). The data is then operated on and summarized (vlookups and other functions) into a 5x80 range (say cols f-j) which constitutes an update of one of several (say 30) existing data sets which are also in 5x80 named ranges. The data brought in has a "tag" or identifier (say in cell a1) that has the name of the named range which is to be updated. The VBA has to read cell a1 and copy the 5x80 update in cols f-j and paste-special-values into the appropriate named range (assume they are all on sheet 2 of the workbook).

    Hope this helps... and thanks.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Can't you use a pivotTable?

    An example workbook would help.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    03-26-2004
    Posts
    4

    Pivot table...

    Roy...thanks for responding.

    Pivot table could do the analysis, but that part I know how to do (but I'm not using a pivot table). Data from any one of many (say 30) scenarios is brought into cols a-e of a sheet, operated on and summarized into a 5x80 named range (which is always in the same place, say cols f-j). That constitutes an update of one of my 30 named ranges (each a different scenario), which are already established and populated. Now I need a macro to select that newly-summarized data (which has a tag (say in cell a1, identifying which of the 30 named ranges for which it is an update) and copy / paste-special-values into the appropriate named range. That is, I need the VBA to direct the paste-special-values into the appropriate named range being updated.

    Thanks...

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    If I understand, you have data imported into a range ( I have named this source_data), then copy it as values to a named range stored in A1

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-26-2004
    Posts
    4

    Works...

    Roy -- That worked fine... I just needed to tweak it a bit for my purposes.

    Tnanks again...

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Glad it helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1