Posts by Miceal

    Re: Vba that get data from sheet that precede the active sheet


    There is something else going on with your VBA ... send me your file with either script installed so that I can see what you are missing.


    FYI ... both scripts are activated when you create a new tab using the icon to the right of the tabs at the bottom of the worksheet.


    P.S. I like jindon's code line ... it is more efficient and reduces my script by a line or two

    Re: Vba that get data from sheet that precede the active sheet


    here is the script using the new tab naming convention:



    if you have troubles ... send me the file with the above script installed so that I can investigate why it isn't working for you

    Re: Vba that get data from sheet that precede the active sheet


    Hi Pevriss,
    I wrote it and tested it in the file you attached. Are you sure that you pasted the above code in the "ThisWorkbook" Object? As for the tab name changes .... I'll have to alter the way it selects the previous day if you want to change the naming convention. Will there be gaps in the date(month, day) tab name for weekends, etc?

    Re: Vba that get data from sheet that precede the active sheet


    add this script to your ThisWorkbook Object and everytime you add a new tab it will pull the info you want from the previous day:


    Re: Adding new CASE Statements for Buttons


    I updated the VBA to hide the FPK button when the MTS button is hit ... you can use the same logic to hide other buttons


    Re: Extract Data from Drop Down List Selection


    regarding 'Also, I was wondering if I added more games than 10 the current list in the "data sheet" would this be displayed in the "Model Sheet" ?':


    if you ensure the named range still covers the area you want copied ... it should work fine.

    Re: Extract Data from Drop Down List Selection


    It stopped working because you added the two columns to sheet("Model"). If you add columns to this sheet, you will need to adjust the script to accomodate the change. The script uses the team selection pull down menus to copy the right data.


    I have updated your file and added a few error traps to handle team data that doesn't exist yet .... see attached..


    Also, for consistency ... I moved your 'PTs Per Minute' to sheets("Data").range("A2") ... that way it is not being overwritten when you select a team

    Re: Excel VBA, SQL Query not working between dates.


    Here is the data I put into the database:
    [TABLE="width: 286"]

    [tr]


    [td]

    DateTimeStamp

    [/td]


    [td]

    QualityTag

    [/td]


    [/tr]


    [tr]


    [td]

    10/17/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/18/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/19/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/20/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/21/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/22/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/23/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/24/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/25/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/26/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/27/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/28/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/29/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/29/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/29/2014 12:00:00 AM

    [/td]


    [td]

    Not Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/29/2014 12:00:00 AM

    [/td]


    [td]

    Not Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/29/2014 12:00:00 AM

    [/td]


    [td]

    Not Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/29/2014 12:00:00 AM

    [/td]


    [td]

    Not Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/29/2014 12:00:00 AM

    [/td]


    [td]

    Not Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/29/2014 12:00:00 AM

    [/td]


    [td]

    Not Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/29/2014 12:00:00 AM

    [/td]


    [td]

    Not Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/30/2014 12:00:00 AM

    [/td]


    [td]

    Not Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/30/2014 12:00:00 AM

    [/td]


    [td]

    Not Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/30/2014 12:00:00 AM

    [/td]


    [td]

    Not Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/30/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/30/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/30/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/30/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/29/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/29/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/29/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/29/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/29/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/29/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/29/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/30/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/30/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/30/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/30/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/30/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/30/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/30/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/30/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/30/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/31/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/31/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/31/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/31/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/31/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/31/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/31/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/31/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    10/31/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    11/1/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    11/2/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    11/3/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    11/4/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    11/5/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    11/6/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    11/7/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    11/8/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    11/9/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [td]

    11/10/2014 12:00:00 AM

    [/td]


    [td]

    Good

    [/td]


    [/tr]


    [/TABLE]


    here is the VBA script I used to querie the database:



    Here is the result of the SQL querie:
    [TABLE="width: 220"]

    [tr]


    [TD="align: right"]10/25/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/26/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/27/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/28/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/29/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/29/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/30/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/30/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/30/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/30/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/29/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/29/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/29/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/29/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/29/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/29/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/29/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/30/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/30/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/30/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/30/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/30/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/30/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/30/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/30/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [tr]


    [TD="align: right"]10/30/2014 0:00[/TD]

    [td]

    Good

    [/td]


    [/tr]


    [/TABLE]


    the script should have worked for you .... check to see that your DateTimeStamp field in the Trends table is set to a date format.

    Re: Excel VBA, SQL Query not working between dates.


    Did you do the changes I recommended above?


    It will convert the dates into a numeric value so you don't need to worry about the date format you are using.


    I could not get your select statement to work on a test data dase that I set up. The select statement that I recommended worked on the test database

    Re: Excel VBA, SQL Query not working between dates.


    I would recommend the following changes:


    Code
    fromDate = Format(Sheets("Main").Cells(15, 2),"####") 
    toDate = Format(Sheets("Main").Cells(17, 2),"####")


    change your dselect statement to:

    SQL
    SELECT * FROM Trends WHERE QualityTag='Good' AND DateTimeStamp >=  " & fromDate & " AND DateTimeStamp <= " & toDate & "")

    Re: Using Cell Contents as Math Operation


    Code
    Sub do_what_olivetwist_wants()
        Range("A2,A4") = "+"
        Range("A6") = (Range("A1") * 1) + (Range("A3") * 1) + (Range("A5") * 1)
    End Sub


    I multiplied the cells x 1 in case your values are stored as text

    Re: Check to see if two of three adjacent cells have matching data


    Code
    Sub Test_for_new()
        Word_ = "new"
        b1 = 0
        b2 = 0
        b3 = 0
        If Len(Split(LCase(Range("B1")), LCase(Word_))(0)) <> Len(Range("B1")) Then b1 = 1
        If Len(Split(LCase(Range("B2")), LCase(Word_))(0)) <> Len(Range("B2")) Then b2 = 1
        If Len(Split(LCase(Range("B3")), LCase(Word_))(0)) <> Len(Range("B3")) Then b3 = 1
        If b1 + b2 + b3 < 2 Or b1 + b2 + b3 = 3 Then Range("B4") = "No" Else Range("B4") = "Yes"
    End Sub


    Here is what it does:
    it splits the cell using the word new ... and if the length of the first split = the length of the full cell ... then the word 'new' isn't in the cell.
    The cell and variable 'Word_' are converted to lowercase to keep everything in the same context.