Eric_B Posted September 26, 2018 Share Posted September 26, 2018 I'm adding onto a program that takes logged data and plots it. To format the new data I'm working with, I copied a bit of another sub that was formatting a different set of data. I edited it down so that it would work with the new data and when I ran it, I got a run time error "1004" with the AutoFill function. The old formatting sub Sub FormatZ2Array() Dim LastRow As Long Worksheets("RawZn2Temp").Activate Range("A1").EntireRow.Insert LastRow = ActiveSheet.UsedRange.Rows.count Range("A1").Value = "Date" Range("B1").Value = "Time" Range("C1").Value = "Zn2.TC5" Range("D1").Value = "Zn2.TC6" Range("E1").Value = "Zn2.TC7" Range("F1").Value = "Zn2.TC8" Range("G1").Value = "Min Temp" Range("H1").Value = "Max Temp" Range("I1").Value = "PL1.DayTimeCheck" Range("G2").Value = MinTemp Range("H2").Value = MaxTemp Range("I2") = "=IF(AND(B2 > " & LastHourFraction & ", B2 < " & HourFraction & ", A2 = DATE(" & CurrentYear & ", " & CurrentMonth & ", " & CurrentDay & ")), 1, 0)" Range("G2:I2").AutoFill Destination:=Range("G2:I" & LastRow + 1) Worksheets("RawZn2Temp").Range("J1").FormulaArray = "=MAX(IF(RawZn2Temp!I:I=1, RawZn2Temp!C:C))" Worksheets("RawZn2Temp").Range("K1").FormulaArray = "=MAX(IF(RawZn2Temp!I:I=1, RawZn2Temp!D:D))" Worksheets("RawZn2Temp").Range("L1").FormulaArray = "=MAX(IF(RawZn2Temp!I:I=1, RawZn2Temp!E:E))" Worksheets("RawZn2Temp").Range("M1").FormulaArray = "=MAX(IF(RawZn2Temp!I:I=1, RawZn2Temp!F:F))" Worksheets("RawZn2Temp").Range("N1").FormulaArray = "=MIN(IF(RawZn2Temp!I:I=1, RawZn2Temp!C:C))" Worksheets("RawZn2Temp").Range("O1").FormulaArray = "=MIN(IF(RawZn2Temp!I:I=1, RawZn2Temp!D:D))" Worksheets("RawZn2Temp").Range("P1").FormulaArray = "=MIN(IF(RawZn2Temp!I:I=1, RawZn2Temp!E:E))" Worksheets("RawZn2Temp").Range("Q1").FormulaArray = "=MIN(IF(RawZn2Temp!I:I=1, RawZn2Temp!F:F))" Call PlotZn2 End Sub And the new one which I edited and is giving me problems. Sub FormatIRSensor1() Dim LastRow As Long Worksheets("RawIRSensor1").Activate Range("A1").EntireRow.Insert LastRow = ActiveSheet.UsedRange.Rows.count Range("A1").Value = "Date" Range("B1").Value = "Time" Range("C1").Value = "IR_Sensors.S1_Average" Range("D1").Value = "Min Temp" Range("E1").Value = "Max Temp" Range("F1").Value = "PL1.DayTimeCheck" Range("D2").Value = MinTemp Range("E2").Value = MaxTemp Range("F2") = "=IF(AND(B2 > " & LastHourFraction & ", B2 < " & HourFraction & ", A2 = DATE(" & CurrentYear & ", " & CurrentMonth & ", " & CurrentDay & ")), 1, 0)" Range("D2:F2").AutoFill Destination:=Range("D2:F" & LastRow + 1) Worksheets("RawIRSensor1").Range("G1").FormulaArray = "=MAX(IF(RawIRSensor1!F:F=1, RawIRSensor1!C:C))" Worksheets("RawIRSensor1").Range("H1").FormulaArray = "=MIN(IF(RawIRSensor1!F:F=1, RawIRSensor1!C:C))" Call PlotS1 End Sub What I'm wondering is if it something that I took from the old sub that not working with the information that the new sub is for, or if it's a problem with the data that I'm trying to format. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 26, 2018 Share Posted September 26, 2018 Test it incrementally, remove the lines and add them back one at a time until it fails, then figure out why that line is the problem. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now