Copy either range to another range based on condition column by column

marimar02

Board Regular
Joined
May 21, 2010
Messages
128
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have 3 tables with 12 columns each (Actuals Jan-Dec (A1:L100), Forecast Jan-Dec(M1:X100) and Full Year Jan-Dec(Y1:AJ100).

I would like a macro to perform following:

Based on weather cells A1 through L1 > 0, copy each column from Actuals Range to Full Year Range same period. So, Jan would be copied over to Jan, Feb to Feb, etc..
Until... cell A1 to L1 value is 0, then it should copy that month's column from Forecast to Full Year. So, i.e. U1 which is September is 0, macro would skip to September in Forecast columns and copy U1:U100 to Sep column in Full Year.

Hope that makes sense. I'm familiar with loop macros but would like it to also move steps to the right which I'm not very comfortable with.

Thanks much...
 
Last edited:

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Kinda played with offset function and got it to work fine. Here is part of the much larger code that makes it work.


Code:
    For j = 0 To 11        Dpndnt1 = Range("A1").Offset(0, j).Value
        Set rng = Range("A1:A100").Offset(0, j)
            If Dpndnt1 > 0 Then
                rng.Select 'copy
                rng.Offset(0, 24).Select 'paste
                'rng.Value = rng.Value
            Else
                rng.Offset(0, 13).Select 'copy
                rng.Offset(0, 24).Select 'paste
                'rng.Value = rng.Value
            End If
    Next j
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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