Hello Excel users
The following two rows works fine. They check if value in cell C4 is correct (202102) and return the value in a modified shape to the cell A1 (2021-02).
Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(AND(ISNUMBER(R[3]C[2]),LEN(R[3]C[2])=6),LEFT(R[3]C[2],4)&""-""&RIGHT(R[3]C[2],2),"""")"
I have tried to create a variable, using the formula below, which is a minor modification from the formula above, but I only get the result "FALSE" in the Message box.
Yearandmonth = FormulaR1C1 = "=IF(AND(ISNUMBER(R[3]C[2]),LEN(R[3]C[2])=6),LEFT(R[3]C[2],4)&""-""&RIGHT(R[3]C[2],2),"""")"
MsgBox Yearandmonth
I am grateful for any help.
Kind regards
Ingemar
The following two rows works fine. They check if value in cell C4 is correct (202102) and return the value in a modified shape to the cell A1 (2021-02).
Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(AND(ISNUMBER(R[3]C[2]),LEN(R[3]C[2])=6),LEFT(R[3]C[2],4)&""-""&RIGHT(R[3]C[2],2),"""")"
I have tried to create a variable, using the formula below, which is a minor modification from the formula above, but I only get the result "FALSE" in the Message box.
Yearandmonth = FormulaR1C1 = "=IF(AND(ISNUMBER(R[3]C[2]),LEN(R[3]C[2])=6),LEFT(R[3]C[2],4)&""-""&RIGHT(R[3]C[2],2),"""")"
MsgBox Yearandmonth
I am grateful for any help.
Kind regards
Ingemar