+ Reply to Thread
Results 1 to 6 of 6

Copy range of cells from sheet to another sheet using offset

  1. #1
    Forum Contributor
    Join Date
    05-19-2015
    Location
    Karnataka, INdia
    MS-Off Ver
    MS Office 2010
    Posts
    277

    Copy range of cells from sheet to another sheet using offset

    Hello,

    How can I use offset to copy a range of cells sheet1.range("C2:G2").value to sheet2.range("B8") using offset and also Cell B8 is a merged cell.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Copy range of cells from sheet to another sheet using offset

    You can use it in any of a thousand ways - but you need to better explain what you want - what you are copying, where you are pasting, and the logic behind the two.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Contributor
    Join Date
    05-19-2015
    Location
    Karnataka, INdia
    MS-Off Ver
    MS Office 2010
    Posts
    277

    Re: Copy range of cells from sheet to another sheet using offset

    I am copying values from sheet1.range("C2:G2") and pasting to sheet2.range("B8"). The destination cell is a merged one. I tried the code however it does not paste to only Cell B8 but also to C8,D8 and so on. I am looking to put the all values in range("C2:G2") in Range("B8") only. I also have to figure out a way to put comma in between each value.

    e.g sheet1 range has 1 2 3 4 5 in five cells, the output in cell B8 should 1,2,3,4,5

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Copy range of cells from sheet to another sheet using offset

    Try it like this - no offset needed (unless you want to loop?):

    Please Login or Register  to view this content.
    As a one liner, that would be:
    Please Login or Register  to view this content.
    Last edited by Bernie Deitrick; 11-29-2016 at 02:59 PM.

  5. #5
    Forum Contributor
    Join Date
    05-19-2015
    Location
    Karnataka, INdia
    MS-Off Ver
    MS Office 2010
    Posts
    277

    Re: Copy range of cells from sheet to another sheet using offset

    Thank you for the code, works fab. I actually have more than one destination cell. but they have gap in between like B8,B10,B15,B17 and so on...... I don't think a loop will help here. Any other workaround, else I have to write around 50 times (Your one liner above) to complete this.

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Copy range of cells from sheet to another sheet using offset

    If there is any logic between where you copy and where you paste - like the paste destination is always 6 rows lower than the row with the data

    Format the cell in column A on each row with the data, and put "Click Me!" as the entry, and use code like this in the worksheet's selection change event:


    1) Copy this code.
    2) Right-Click the sheet tab of "Data"
    3) Select "View Code"
    4) Paste the code into the window that appears.

    Please Login or Register  to view this content.
    You could also do the reverse, and use formulas in cells of column B on Sheet1, like this in B8:

    =Data!B2 & "," & Data!C2 & "," & Data!D2 & "," & Data!E2 & "," & Data!F2
    Last edited by Bernie Deitrick; 11-29-2016 at 05:01 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Help! - Copy Range (Sheet1,A10:F50), Paste Range (Sheet 2,A1:F41), Offset Range & Repeat
    By cjtimmer in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-30-2015, 06:27 PM
  2. Copy range of cells from one sheet to another
    By audiorij in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-17-2015, 09:58 AM
  3. Creating a copy button to copy range of cells to a different sheet
    By 5degrees in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-15-2013, 12:21 PM
  4. Replies: 0
    Last Post: 01-08-2013, 11:34 PM
  5. Macro: Count rows in sheet A, copy count in sheet B, paste offset in sheet A
    By Agent:Orange in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-19-2011, 07:56 AM
  6. Copy a range to a different sheet and offset it
    By pktrusty in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-29-2010, 08:55 AM
  7. [SOLVED] Loop Through A Range, Find Cells > 1, Copy Offset To Another Sheet
    By bugmenot in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-25-2008, 06:30 PM

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