Macro that shifts data to new columns based on row limits

rwmill9716

Active Member
Joined
May 20, 2006
Messages
495
Office Version
  1. 2013
Platform
  1. Windows
I need a macro that will: (1) copies Columns C and E (from row 8 on) to Columns G and H, (2) reads shift limits in Cells F5 and G5, (3), copies data in Columns E and F, (4) writes that data in Columns G and H between the shift limits.


Excel 2012
CDEFGH
4Shift Data to RowEnd Shift56.5
5121655.5
6Ppk =#DIV/0!
7Date/TimeList 1Date/TimeList 2DateComposite
801/01/16101/05/1610001/01/161
901/02/16201/06/1610101/02/162
1001/02/16301/07/1610201/02/163
1101/04/16401/08/1610301/04/164
1201/05/16501/09/1610401/05/16100
1301/06/16601/06/16101
1401/08/16701/07/16102
1501/09/16801/08/16103
1601/10/16901/09/16104
1701/10/161001/10/1610
1801/11/161101/11/1611
1901/12/161201/12/1612
2001/13/161301/13/1613
2101/14/161401/14/1614
2201/15/161501/15/1615
2301/17/161601/17/1616
2401/17/161701/17/1617
2501/18/161801/18/1618
2601/19/161901/19/1619
2701/21/162001/21/1620
2801/21/162101/21/1621
Sheet4
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Try:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG08Dec26
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Set[/COLOR] Rng = Range("C" & [g5] + 1, Range("C" & Rows.Count).End(xlUp))
Range("C8:C" & [f5] - 1).Resize(, 2).Copy Cells(8, "G")
Range("E8:E" & [f5]).Resize(, 2).Copy Cells([f5], "G")
Rng.Resize(, 2).Copy Cells([g5] + 1, "G")
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Mick,

I ran into a problem that I didn't expect and wonder if there's an easy fix. All the data in Columns C, D, E and F are array members. I need the data pasted into columns G and H to be without the array formula, just the dates and numbers. I know that I can do this with a normal cut and paste operation.

Thanks,

Ric
 
Upvote 0
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG09Dec17
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Set[/COLOR] Rng = Range("C" & [g5] + 1, Range("C" & Rows.Count).End(xlUp))
Range("C8:C" & [f5] - 1).Resize(, 2).Copy
    Cells(8, "G").PasteSpecial Paste:=xlPasteValues
Range("E8:E" & [f5]).Resize(, 2).Copy
    Cells([f5], "G").PasteSpecial Paste:=xlPasteValues
Rng.Resize(, 2).Copy
    Cells([g5] + 1, "G").PasteSpecial Paste:=xlPasteValues
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,287
Members
452,902
Latest member
Knuddeluff

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