hi,
i have the following Macro which is supposed to insert a formula in H2, I2, & J2 and copy it down to the last row of column H, I, & J which have data in column A.
it places the formula in the correct cell, however then instead of copying the formula to the last row of column H, I & J it copys it into Cells H1, I1, J1
i need to be able to do this on several sheets where the number of rows of data in column A are not always going to be the same
'Capture Last Row
Dim lastrowa As Long
lastrowa = ActiveSheet.Range("a" & Rows.Count).End(xlUp).Row
'Add Columns Todays Status, Update, & Reg Notes
Sheets("OldData").Select
Range("H1:J1").Select
Selection.Font.Bold = True
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("H1").Select
ActiveCell.FormulaR1C1 = "Todays Status"
Range("I1").Select
ActiveCell.FormulaR1C1 = "UPDATE"
Range("J1").Select
ActiveCell.FormulaR1C1 = "Reg Notes"
Columns("H:J").EntireColumn.AutoFit
'Check Todays Reg
Range("H2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-2],RegData!C[-4]:C[-3],2,FALSE)),""DEGRADED"",""OPERATIONAL"")"
Selection.AutoFill Destination:=Range("H2:H" & lastrowa)
'Update Date
Range("I2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-7]=RC[-1],RC[-5],TODAY())"
Selection.AutoFill Destination:=Range("I2:I" & lastrowa)
Columns("I:I").Select
Selection.NumberFormat = "m/d/yyyy"
'Update Reg Status
Range("J2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-8]=RC[-2],RC[-3],CONCATENATE(RC[-3],"" "",TEXT(RC[-6],""mm/dd/yyyy"")))"
Selection.AutoFill Destination:=Range("J2:J" & lastrowa)
i appreciate your help!!!
i have the following Macro which is supposed to insert a formula in H2, I2, & J2 and copy it down to the last row of column H, I, & J which have data in column A.
it places the formula in the correct cell, however then instead of copying the formula to the last row of column H, I & J it copys it into Cells H1, I1, J1
i need to be able to do this on several sheets where the number of rows of data in column A are not always going to be the same
'Capture Last Row
Dim lastrowa As Long
lastrowa = ActiveSheet.Range("a" & Rows.Count).End(xlUp).Row
'Add Columns Todays Status, Update, & Reg Notes
Sheets("OldData").Select
Range("H1:J1").Select
Selection.Font.Bold = True
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("H1").Select
ActiveCell.FormulaR1C1 = "Todays Status"
Range("I1").Select
ActiveCell.FormulaR1C1 = "UPDATE"
Range("J1").Select
ActiveCell.FormulaR1C1 = "Reg Notes"
Columns("H:J").EntireColumn.AutoFit
'Check Todays Reg
Range("H2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-2],RegData!C[-4]:C[-3],2,FALSE)),""DEGRADED"",""OPERATIONAL"")"
Selection.AutoFill Destination:=Range("H2:H" & lastrowa)
'Update Date
Range("I2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-7]=RC[-1],RC[-5],TODAY())"
Selection.AutoFill Destination:=Range("I2:I" & lastrowa)
Columns("I:I").Select
Selection.NumberFormat = "m/d/yyyy"
'Update Reg Status
Range("J2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-8]=RC[-2],RC[-3],CONCATENATE(RC[-3],"" "",TEXT(RC[-6],""mm/dd/yyyy"")))"
Selection.AutoFill Destination:=Range("J2:J" & lastrowa)
i appreciate your help!!!