Jump to content

Eric_B

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by Eric_B

  1. 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.

  2. Ignore what I previously had, I just thought of an Idea and I wanted to check with you. The main idea of what I'm doing is adding to the css system that was in there before I started working on it.

    Can I set up input/ oninput to call the function if the "not" logical operator was used.

    like <input [[175]]!=0 oninput function()> then use the document.getElementById(b[[141]]).style.backgroundColor = "(insert color)" in the script.

    That way for Id's b0-b100, the background is that color when [[175]] != 0. Otherwise the program stays its current course.

  3. 3 hours ago, dsonesuk said:

    That a big NO! you can't! have it in the style tag.

    The style tags along with css are placed between <head>...</head>

    All the hash numbers will be treated as html text not JavaScript, they need to be a string applied to a defined variable, or placed in an array.

    style.xxxxx = "xxxx" need to attached to a ref to a element through either document.getElementById('nnnn') singular id ref, document.getElementsByTagName('nnnn').[idx] and also document.getElementsByClassName('nnnn').[idx], where 'nnnn' is a specific named value and where 'idx' is a index number representing a specific element of multiple identical matching 'nnnn' value.

    JavaScript code is triggered by specific events, you already using one 'onload' which will call a function specified 'bundle()' when page has been fully loaded. Other events are 'onclick', 'onmouseover', 'onmouseout', 'onsubmit', 'onkeypress' and 'onkeyup'. These are just a few events that are used to trigger a JavaScript function call.

    I should go to JavaScript tutorials, to learn more about how JavaScript works.

    https://www.w3schools.com/js/default.asp

    [[175]] is a value being pulled from Red Lion crimson 3 with a default value of zero, that changes depending on user input. Now if I used it in the call statement <input id="[[175]]" oninput="PivaticStopTime();> will this call the function or am I misunderstanding input and oninput?  

  4. I'm trying to create a script that contains an if/else statement that uses an outside input to change the color of a box in the html file. Currently I am not seeing any changes, so right now I'm checking if the script is even being noticed and ran. I'll admit that I'm not very good at this, so I apologize if these are really simple problems to fix or that they've been fixed before and I missed it when searching for other posts. If it's the latter, could you send me a link.

    Placement: Currently the script is inside the a style tag, and both are outside the body. Should I not have it in the style tag? Should I keep it outside of the body? If the issue is placement, where should I place it.

    Currently the if/else statement is not in a function. Does it need to be in a function? If so, how should I set it up so the function gets called every time, but does nothing until the if condition is met? if I don't need it to be a function to run this, how else can I set it up so it will run?

     

    Here's the part of the code that I'm working on, Ignore the contents as all I'm looking for is how to get the script to be noticed and ran.

    <script= text/javascript>
        var StopTimePivatic = [[175]];
        if (StopTimePivatic != 0){
            #b[[141]]{
            style.background-color= silver;
            }
        }
        else{
            #b80, #b81, #b82, #b83, #b84, #b85, #b86, #b87, #b88, #b89, #b90 {
            style.background-color = Yellow;
            style.color = black;
            }
            
            #b0, #b1, #b2, #b3, #b4, #b5, #b6, #b7, #b8, #b9,
            #b10, #b11, #b12, #b13, #b14, #b15, #b16, #b17, #b18, #b19,
            #b20, #b21, #b22, #b23, #b24, #b25, #b26, #b27, #b28, #b29,    
            #b30, #b31, #b32, #b33, #b34, #b35, #b36, #b37, #b38, #b39,
            #b40, #b41, #b42, #b43, #b44, #b45, #b46, #b47, #b48, #b49,
            #b50, #b51, #b52, #b53, #b54, #b55, #b56, #b57, #b58, #b59,
            #b60, #b61, #b62, #b63, #b64, #b65, #b66, #b67, #b68, #b69,
            #b70, #b71, #b72, #b73, #b74, #b75, #b76, #b77, #b78, #b79 {
                style.background-color = red;
            }
        }
    </script>
    </style>
    <body onload="bundle()">

     

    As I said previously, If as similar problem to this has been solved, please let me know where i can find it.

×
×
  • Create New...