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

marimar02

Board Regular
Joined
May 21, 2010
Messages
96
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:

marimar02

Board Regular
Joined
May 21, 2010
Messages
96
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
 

Forum statistics

Threads
1,077,614
Messages
5,335,253
Members
399,009
Latest member
twcaddell

Some videos you may like

This Week's Hot Topics

Top