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.
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.
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
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.
Try it like this - no offset needed (unless you want to loop?):
As a one liner, that would be:Please Login or Register to view this content.
Please Login or Register to view this content.
Last edited by Bernie Deitrick; 11-29-2016 at 02:59 PM.
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.
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.
You could also do the reverse, and use formulas in cells of column B on Sheet1, like this in B8:Please Login or Register to view this content.
=Data!B2 & "," & Data!C2 & "," & Data!D2 & "," & Data!E2 & "," & Data!F2
Last edited by Bernie Deitrick; 11-29-2016 at 05:01 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks