Hello Gurus,
I am new to excel VBA. I am not familiar with variables and loop, hence trying to use activecell.formula. I know this is not the efficient way to do it, but as I am new and just learning found this easy to do.
The following formula works when manually typing in a cell.
Formula:
="=CORREL(L"&ROW()&":BG"&ROW()&",'Master SNP Database'!G" &MATCH(C2, 'Master SNP Database'!C:C,0)& ":BB" &MATCH(C2,'Master SNP Database'!C:C,0)&")"
Desired Result:
=CORREL(L2:BG2,'Master SNP Database'!G530:BB530)
But the same formula when entered in VBA gives compile error: Syntax error. Can someone point me how to overcome the error.
VBA code:
Sub test()
ActiveCell.FormulaR1C1 = "=CORREL(L"&ROW()&":BG"&ROW()&",'Master SNP Database'!G" &MATCH(C2, 'Master SNP Database'!C:C,0)& ":BB" &MATCH(C2,'Master SNP Database'!C:C,0)&")"
End Sub
My excel VBA skills are basic but if given a direction I can work my way up.
TIA.
I am new to excel VBA. I am not familiar with variables and loop, hence trying to use activecell.formula. I know this is not the efficient way to do it, but as I am new and just learning found this easy to do.
The following formula works when manually typing in a cell.
Formula:
="=CORREL(L"&ROW()&":BG"&ROW()&",'Master SNP Database'!G" &MATCH(C2, 'Master SNP Database'!C:C,0)& ":BB" &MATCH(C2,'Master SNP Database'!C:C,0)&")"
Desired Result:
=CORREL(L2:BG2,'Master SNP Database'!G530:BB530)
But the same formula when entered in VBA gives compile error: Syntax error. Can someone point me how to overcome the error.
VBA code:
Sub test()
ActiveCell.FormulaR1C1 = "=CORREL(L"&ROW()&":BG"&ROW()&",'Master SNP Database'!G" &MATCH(C2, 'Master SNP Database'!C:C,0)& ":BB" &MATCH(C2,'Master SNP Database'!C:C,0)&")"
End Sub
My excel VBA skills are basic but if given a direction I can work my way up.
TIA.