Loop through range of merged cells and copy each row's cell values - 1 row per new sheet

cmancu

Board Regular
Joined
Jan 25, 2006
Messages
52
Office Version
  1. 365
Platform
  1. Windows
I have found similar VBA code loops to copy and paste values on the board, but not quite this. (Sorry for descriptive only here)
I have formulas calculating results in Sheet("Instructions"), cells B5:T100. Each row only contains 6 formulas due to some merged columns (B-G), (H) (I-K), (L-N), (O-Q), (R-T).
Some leading rows and trailing rows usually result in blanks, so there are not always 95 rows of values to copy. BUT, where there is data, rows are ALWAYS contiguous rows.
So I may have row 5 to row 20 blank, then rows 21 to 45 showing results, then 46 to 100 blank. Changes each day.
When a row does contains data, (B-G) (I-K), (L-N), (O-Q), (R-T) are never blank. (H) may sometimes contain a blank result, but it can still be copied.
So I would like to loop through the cells in each non-blank row B5:T100 and copy the 6 values to other sheets, 1 row per sheet, but pasted to different cell locations.
The receiving sheets 1-95 (already in my workbook) have matching merged columns where the values will be pasted if that helps.
Each recipient sheet will receive the values in the same cell positions shown below, so

For each row with data in Sheet("Instructions"B5:T100)
(B:G) copies value to Sheet1(B2:G2)
(H) copies value to Sheet1(H2)
(I-K) copies value to Sheet1(C3:E3)
(L-N) copies value to Sheet1(C4:E4)
(O-Q) copies value to Sheet1(C5:E5)
(R-T) copies value to Sheet1(C6:E6)

Then go to next row with data, and copy the same merged cells to same merged cells in Sheet2, and so on.
Repeat to last row of data in "Instructions" to Sheet(nth).

Sorry again for long descriptive, but I think this is relatively easy from similar examples I've seen. Just wish I knew how to code.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
merged cells are regarded by many here as an abomination as they create numerous unwelcomed problems especially when using sort, copy, paste, or move data & trying to create code to work with merged cells can be a real headache. General advice would be to avoid using merging cells in your project.

Have a look at this article for an alternative approach you may want to consider: Excel: Don’t Merge Those Cells! Here is an Alternative. – Office Bytes

Dave
 
Upvote 0
Solution
merged cells are regarded by many here as an abomination as they create numerous unwelcomed problems especially when using sort, copy, paste, or move data & trying to create code to work with merged cells can be a real headache. General advice would be to avoid using merging cells in your project.

Have a look at this article for an alternative approach you may want to consider: Excel: Don’t Merge Those Cells! Here is an Alternative. – Office Bytes

Dave
Thanks Dave. I never knew that. I inherited the sheet with the merges, and was trying to create from that, but I'm sure I can rework it.
Appreciate the link. Solved.
 
Upvote 0

Forum statistics

Threads
1,214,994
Messages
6,122,633
Members
449,092
Latest member
bsb1122

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top