Consulting

Results 1 to 6 of 6

Thread: Need help with Range

  1. #1
    VBAX Newbie
    Joined
    Jun 2009
    Posts
    5
    Location

    Need help with Range

    Hi
    Help me to solve the range messup. I want to copy multiple column range from one sheet to another sheet. I tried with

    Sheet1.Select
    ThisWorkbook.Sheets("Sheet1").Range("D33 50", "E33 :E50", "F33 :F50", "J33 :J50", "K33 :K50", "L33 :L50", "R33 :R50", "S33 :S50").Select
    Selection.Copy
    Sheet3.Select
    ThisWorkbook.Sheets("Sheet3").Range("B" & nr, "B" & nr + 17, "C" & nr, "C" & nr + 17, "D" & nr, "D" & nr + 17, "E" & nr, "E" & nr + 17, "F" & nr, "F" & nr + 17, "G" & nr, "G" & nr + 17, "H" & nr, "H" & nr + 17, "I" & nr, "I" & nr + 17) _
    .PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False

    Your help is appriciated in advance
    Thanks

  2. #2
    Site Admin VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,005
    Location
    You don't say where you want it copying to as nr isn't shown as an integer here, you would be better off supplying a workbook with your query and a better explanation.
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,455
    Location
    [vba]

    With ThisWorkbook

    .Sheets("Sheet1").Range("D33:F50").Copy
    .Sheets("Sheet3").Range("B" & nr).PasteSpecial Paste:=xlValues
    .Sheets("Sheet1").Range("J33:L50").Copy
    .Sheets("Sheet3").Range("E" & nr).PasteSpecial Paste:=xlValues
    .Sheets("Sheet1").Range("R33:S50").Copy
    .Sheets("Sheet3").Range("H" & nr).PasteSpecial Paste:=xlValues
    Application.CutCopyMode = False
    End With
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    Site Admin VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,005
    Location
    Bob, full marks on sorting that mudlde out, however, the OP also wants to paste to nr+17, i wasnt sure whether it was supposed to be ("B" & nr & ":" & "B" & nr+17) as a range, well for me at least it wasn't clear.
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,455
    Location
    Quote Originally Posted by Simon Lloyd
    Bob, full marks on sorting that mudlde out, however, the OP also wants to paste to nr+17, i wasnt sure whether it was supposed to be ("B" & nr & ":" & "B" & nr+17) as a range, well for me at least it wasn't clear.
    He does, but as the source is 18 rows, the paste should cater for that.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    VBAX Newbie
    Joined
    Jun 2009
    Posts
    5
    Location
    Thanks guys

Posting Permissions

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