+ Reply to Thread
Results 1 to 3 of 3

Copy and Paste 2 columns from a named range?

  1. #1
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Copy and Paste 2 columns from a named range?

    Hi all,

    I have some code that selects a named range and then copies it to a location, is it possible to select the named range but just copy the first 18 rows x 2 columns out of it, so if the named range dimension was 18x4 just copy the contents of the named from columns A & B and paste to location. I would also need to copy the code to another module where in that instance it would copy the contents of the named range from columns C & D.

    Any ideas?, Here's the code im using to select the named range,

    Regards,
    Simon

    Sub datachange()
    Sheets("User Data").Visible = True

    Application.Goto Reference:=Range("B3").Value
    Selection.Copy
    Sheets("Data View").Select
    Range("B5").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Sheets("User Data").Activate
    ActiveWindow.SelectedSheets.Visible = False
    Sheets("Data View").Select
    Range("A1").Select
    Exit Sub
    End Sub

  2. #2
    Norman Jones
    Guest

    Re: Copy and Paste 2 columns from a named range?

    Hi Simon Try something like:

    Dim rng As Range
    Dim rng1 As Range
    Dim rng2 As Range


    Set rng = Range("NamedRange")

    Set rng1 = rng.Resize(18, 2)
    Set rng2 = rng.Offset(, 2).Resize(18, 2)



    ---
    Regards,
    Norman



    "Simon Lloyd" <Simon.Lloyd.28j5jo_1148840705.1283@excelforum-nospam.com>
    wrote in message
    news:Simon.Lloyd.28j5jo_1148840705.1283@excelforum-nospam.com...
    >
    > Hi all,
    >
    > I have some code that selects a named range and then copies it to a
    > location, is it possible to select the named range but just copy the
    > first 18 rows x 2 columns out of it, so if the named range dimension
    > was 18x4 just copy the contents of the named from columns A & B and
    > paste to location. I would also need to copy the code to another module
    > where in that instance it would copy the contents of the named range
    > from columns C & D.
    >
    > Any ideas?, Here's the code im using to select the named range,
    >
    > Regards,
    > Simon
    >
    > Sub datachange()
    > Sheets("User Data").Visible = True
    >
    > Application.Goto Reference:=Range("B3").Value
    > Selection.Copy
    > Sheets("Data View").Select
    > Range("B5").Select
    > Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
    > SkipBlanks _
    > :=False, Transpose:=False
    > Sheets("User Data").Activate
    > ActiveWindow.SelectedSheets.Visible = False
    > Sheets("Data View").Select
    > Range("A1").Select
    > Exit Sub
    > End Sub
    >
    >
    > --
    > Simon Lloyd
    > ------------------------------------------------------------------------
    > Simon Lloyd's Profile:
    > http://www.excelforum.com/member.php...fo&userid=6708
    > View this thread: http://www.excelforum.com/showthread...hreadid=546299
    >




  3. #3
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Thanks Norman..............Worked a treat!

    Regards,
    Simon

+ 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