I'm a new user of macros
I have recorded a macro were it measures correlation between the cells.
My problem is that I have to do that procedure for a lot combinations that's why I record the macro
My cells range that is recorded starts from the cells JSL6-JU6. I want to make the same procedure with the help of macros for the range of The following 52 Cell but I will start from JUM.
I tried all the possible ways my sheet goes like this:
CELL= Formula
JWM6: =CORREL(JJ6:JJ43, B6:B43)
JMN6: =CORREL(JJ6:JJ43, C6:C43)
JW06: =CORREL(JJ6:JJ43, D6:D43)
JMp6: =CORREL(JJ6:JJ43, E6:E43)...etc
When I add the first formula and use the scroll function it goes like this:
JWM6: =CORREL(JJ6:JJ43, B6:B43)
JMN6: =CORREL(JK6:JK43, C6:C43)
I need a macro to do it automatically or to make correlation function to remain stable the first array and the second one to move.
The Code is this one below:
Sub Macro1()
'
' Macro1 Macro
'
'
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7002]:R[37]C[-7002],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7003]:R[37]C[-7003],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7004]:R[37]C[-7004],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7005]:R[37]C[-7005],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7006]:R[37]C[-7006],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7007]:R[37]C[-7007],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7008]:R[37]C[-7008],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7009]:R[37]C[-7009],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7010]:R[37]C[-7010],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7011]:R[37]C[-7011],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7012]:R[37]C[-7012],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7013]:R[37]C[-7013],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7014]:R[37]C[-7014],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7015]:R[37]C[-7015],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7016]:R[37]C[-7016],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7017]:R[37]C[-7017],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7018]:R[37]C[-7018],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7019]:R[37]C[-7019],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7020]:R[37]C[-7020],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7021]:R[37]C[-7021],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7022]:R[37]C[-7022],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7023]:R[37]C[-7023],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7024]:R[37]C[-7024],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7025]:R[37]C[-7025],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7026]:R[37]C[-7026],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7027]:R[37]C[-7027],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7028]:R[37]C[-7028],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7029]:R[37]C[-7029],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7030]:R[37]C[-7030],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7031]:R[37]C[-7031],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7032]:R[37]C[-7032],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7033]:R[37]C[-7033],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7034]:R[37]C[-7034],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7035]:R[37]C[-7035],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7036]:R[37]C[-7036],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7037]:R[37]C[-7037],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7038]:R[37]C[-7038],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7039]:R[37]C[-7039],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7040]:R[37]C[-7040],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7041]:R[37]C[-7041],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7042]:R[37]C[-7042],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7043]:R[37]C[-7043],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7044]:R[37]C[-7044],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7045]:R[37]C[-7045],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7046]:R[37]C[-7046],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7047]:R[37]C[-7047],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7048]:R[37]C[-7048],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7049]:R[37]C[-7049],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7050]:R[37]C[-7050],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7051]:R[37]C[-7051],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7052]:R[37]C[-7052],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7053]:R[37]C[-7053],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(1, 0).Range("A1").Select
End Sub
I have recorded a macro were it measures correlation between the cells.
My problem is that I have to do that procedure for a lot combinations that's why I record the macro
My cells range that is recorded starts from the cells JSL6-JU6. I want to make the same procedure with the help of macros for the range of The following 52 Cell but I will start from JUM.
I tried all the possible ways my sheet goes like this:
CELL= Formula
JWM6: =CORREL(JJ6:JJ43, B6:B43)
JMN6: =CORREL(JJ6:JJ43, C6:C43)
JW06: =CORREL(JJ6:JJ43, D6:D43)
JMp6: =CORREL(JJ6:JJ43, E6:E43)...etc
When I add the first formula and use the scroll function it goes like this:
JWM6: =CORREL(JJ6:JJ43, B6:B43)
JMN6: =CORREL(JK6:JK43, C6:C43)
I need a macro to do it automatically or to make correlation function to remain stable the first array and the second one to move.
The Code is this one below:
Sub Macro1()
'
' Macro1 Macro
'
'
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7002]:R[37]C[-7002],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7003]:R[37]C[-7003],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7004]:R[37]C[-7004],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7005]:R[37]C[-7005],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7006]:R[37]C[-7006],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7007]:R[37]C[-7007],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7008]:R[37]C[-7008],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7009]:R[37]C[-7009],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7010]:R[37]C[-7010],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7011]:R[37]C[-7011],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7012]:R[37]C[-7012],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7013]:R[37]C[-7013],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7014]:R[37]C[-7014],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7015]:R[37]C[-7015],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7016]:R[37]C[-7016],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7017]:R[37]C[-7017],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7018]:R[37]C[-7018],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7019]:R[37]C[-7019],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7020]:R[37]C[-7020],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7021]:R[37]C[-7021],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7022]:R[37]C[-7022],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7023]:R[37]C[-7023],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7024]:R[37]C[-7024],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7025]:R[37]C[-7025],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7026]:R[37]C[-7026],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7027]:R[37]C[-7027],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7028]:R[37]C[-7028],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7029]:R[37]C[-7029],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7030]:R[37]C[-7030],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7031]:R[37]C[-7031],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7032]:R[37]C[-7032],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7033]:R[37]C[-7033],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7034]:R[37]C[-7034],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7035]:R[37]C[-7035],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7036]:R[37]C[-7036],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7037]:R[37]C[-7037],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7038]:R[37]C[-7038],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7039]:R[37]C[-7039],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7040]:R[37]C[-7040],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7041]:R[37]C[-7041],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7042]:R[37]C[-7042],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7043]:R[37]C[-7043],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7044]:R[37]C[-7044],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7045]:R[37]C[-7045],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7046]:R[37]C[-7046],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7047]:R[37]C[-7047],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7048]:R[37]C[-7048],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7049]:R[37]C[-7049],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7050]:R[37]C[-7050],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7051]:R[37]C[-7051],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7052]:R[37]C[-7052],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=CORREL(RC[-7053]:R[37]C[-7053],RC[-7263]:R[37]C[-7263])"
ActiveCell.Offset(1, 0).Range("A1").Select
End Sub