+ Reply to Thread
Results 1 to 11 of 11

Why is my the CF and VBA in my spreadsheet not working properly???

  1. #1
    Registered User
    Join Date
    08-07-2013
    Location
    maryport
    MS-Off Ver
    Excel 2013
    Posts
    54

    Why is my the CF and VBA in my spreadsheet not working properly???

    Can someone help, i dont know why this wont do what its supposed to and im stuck....

    I set it so if you double click on a box it turns green, or red depending on color already. when i input the dates and times they dont format correctly and i cant change them, ive been through the CF rules and they seem fine, the VBA seems fine, where am i going wrong????

    Check Call problem.xlsm
    Last edited by brucey2343; 09-16-2013 at 01:35 PM.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Why is my spreadsheet not working properly???

    Sorry I cannot respond yet.

  3. #3
    Registered User
    Join Date
    08-07-2013
    Location
    maryport
    MS-Off Ver
    Excel 2013
    Posts
    54

    Re: Why is my the CF and VBA in my spreadsheet not working properly???

    is that better? sorry

  4. #4
    Registered User
    Join Date
    08-07-2013
    Location
    maryport
    MS-Off Ver
    Excel 2013
    Posts
    54

    Re: Why is my the CF and VBA in my spreadsheet not working properly???

    hello?????

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Why is my the CF and VBA in my spreadsheet not working properly???

    Title has been changed, please feel free to continue thread.

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Why is my the CF and VBA in my spreadsheet not working properly???

    Hi the colour change macro works fine for me.

    I cannot see rows 3 or 4 for some reason. cannot unhide or change the row hieght so cannot help with the dates issue.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Why is my the CF and VBA in my spreadsheet not working properly???

    Without an explanation of what behavior you are expecting it is very difficult to guess what you have in mind. I haven't the faintest idea what you are trying to show here, but I see a couple of problems in a conditional formatting rule. Your CF rule checking for LATE is clear enough. But you have a whole bunch of other rules that looks like copies and they have overlapping ranges. That's really going to cause you a problem. View the rules and select "Show formatting rules for: This worksheet" and you'll see what I mean. This may work but it's a lot cleaner to have one rule with the entire range. This usually happens when you start copying and pasting and inserting things.

    This duplicated rule looks strange for two reasons. Let's look at the one that applies to D6.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Here's where I think you have the real problem: The $ in D$6 says regardless of what row the cell is in, check what's in row 6. For example, when deciding whether to apply this formatting to the cell E10, which is A GLallombardo at 9:00, it's going to look at the cell for M Buxton for 9:00.

    Also, the constant at the end is 12:10 AM. Calculating the current time minus the heading time and comparing it to 12:10 AM seems a little odd and I can't figure out what you are trying to do there.

    It's an IF. That is not an error, but it is the equivalent of

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    which would probably be clearer.

    Also note the rules you have and the order in which they execute. If multiple rules are true then the last one will be applied last. I can't tell if you have the rules in the correct order for what you want to do.

    Cell D11 is blank.

    Row numbers in your formulas in the "time" range use $ for the row. That is not an error but it prevents you from being able to copy the formula to other cells. It is a best practice to avoid $ unless necessary. Also, the logic has a similar issue as the CF formula above. It is not an error but you are using IF to stack up two conditions and the FALSE alternatives are both blank. For the formula in D6, this is the logical equivalent of

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I rearranged the logical comparison there to make it clearer that you are testing to see if D$5 is between $B6 and $C6. This is a just a suggestion for readability, a matter of style.

    I suggest you indent your code and add a little space to make it readable. Also, there is no need for variable t. You can just use Target, as you do in the rest of the code (see red text). However, none of this is causing a problem.

    You use the variable a but it is undeclared and unset. This effectively causes you to blank out the cell that has been double clicked, regardless of what else you might do. See last line of code before End Sub.
    Please Login or Register  to view this content.
    Last edited by 6StringJazzer; 09-16-2013 at 09:20 PM. Reason: Added blue text
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  8. #8
    Registered User
    Join Date
    08-07-2013
    Location
    maryport
    MS-Off Ver
    Excel 2013
    Posts
    54

    Re: Why is my the CF and VBA in my spreadsheet not working properly???

    Check Call problem 2.xlsm

    OK, ive solved the problems with the CF, but the VBA still wont work!

    My ideal outcome: In the range "times" (D6:AA11), if a square is white and a user double clicks it, nothing happens, if its red, it turns green, and if its green it turns red.

    It JUST WONT WORK

    Please help

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Why is my the CF and VBA in my spreadsheet not working properly???

    If you use VBA to check the color of a cell, it considers only the color that is explicitly set; it does not know anything about the color set by conditional formatting. In your case all the cells look like "no fill" to VBA. YOu can easily see this if you step through the code in the debugger.

    For your Sub to work, instead of checking the color, you have to check the condition that is used to set the conditional formatting. In addition, even if you do that, your conditional formatting rules will override that and you still won't see the color change.

    You need to rethink your whole solution in terms of the interaction between CF and VBA.

  10. #10
    Registered User
    Join Date
    08-07-2013
    Location
    maryport
    MS-Off Ver
    Excel 2013
    Posts
    54

    Re: Why is my the CF and VBA in my spreadsheet not working properly???

    So how would i achieve my goal??

  11. #11
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Why is my the CF and VBA in my spreadsheet not working properly???

    One solution is to do everything in VBA. By deconstructing your conditional formatting logic I built the VBA code in the attachment. The conditional formatting has been removed.

    See attached.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] datetime.now function not working properly upon entering into spreadsheet.
    By emilyloz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-02-2013, 10:20 AM
  2. VBA not working properly
    By stevemills04 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-26-2013, 02:56 PM
  3. UDF not working properly
    By demuro1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-09-2008, 04:36 PM
  4. [SOLVED] datasort not working properly
    By ludditefreak in forum Excel General
    Replies: 1
    Last Post: 03-08-2006, 11:10 AM
  5. [SOLVED] data subtotalling isnt working properly on my spreadsheet
    By robert in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-19-2006, 11:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1