Hey there,
I would like my macro to insert a function into a cell. The function works in Excel but if I use the function in my macro it gives an error. Any idea how to write it correctly?
Sub Prepare_data()
Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1").Select
ActiveCell.FormulaR1C1 = "Version"
Range("A2").Select
ActiveCell.FormulaR1C1 = "=MID(CELL(""filename"");FIND(""."";CELL(""filename""))-1;1)"
LastRow = ActiveSheet.UsedRange.Rows.Count
Range("A2").AutoFill Destination:=Range("A2:A" & LastRow)
End sub
I would like my macro to insert a function into a cell. The function works in Excel but if I use the function in my macro it gives an error. Any idea how to write it correctly?
Sub Prepare_data()
Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1").Select
ActiveCell.FormulaR1C1 = "Version"
Range("A2").Select
ActiveCell.FormulaR1C1 = "=MID(CELL(""filename"");FIND(""."";CELL(""filename""))-1;1)"
LastRow = ActiveSheet.UsedRange.Rows.Count
Range("A2").AutoFill Destination:=Range("A2:A" & LastRow)
End sub