+ Reply to Thread
Results 1 to 24 of 24

VBA Multiple Conditional Formatting

  1. #1
    Registered User
    Join Date
    03-25-2012
    Location
    Melbourne, Victoria
    MS-Off Ver
    Excel 2007
    Posts
    82

    VBA Multiple Conditional Formatting

    I have tried macro recorder with no luck I can get it to work if I use excel conditional formatting but I need this to be a VBA macro

    All the conditional formatting help I see on all the sites don't seem to help with what I want.

    I need to be able run a macro anytime even on open or close or save.

    =if(and(Column A has the word "Dial" or "Special" or "Install" and part of the word so maybe using a wildcard) and (Column F has the word "Booked") and (Column J has a date in it I need the Columns from Row A:M to turn Blue.

    I then have about 30 more conditions to add to the macro.Works Project.xlsm
    HTML Code: 
    Last edited by slohman; 03-25-2014 at 01:47 AM.

  2. #2
    Registered User
    Join Date
    02-21-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: VBA Multiple Conditional Formatting

    Not sure if you could adpt this code for what you want it to do.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-25-2012
    Location
    Melbourne, Victoria
    MS-Off Ver
    Excel 2007
    Posts
    82

    Re: VBA Multiple Conditional Formatting

    Thanks but I tried something like that but I need it to colour all the Columns from A4:M???

    I also need 3 cases on the same line like an if and statement

  4. #4
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: VBA Multiple Conditional Formatting

    Hi Slohman
    Have a look at this. I've commented out your worksheet change code, but only to stop it working when I was testing my code. Hopefully it'll give you something to work on & work with. I think it's doing what you need. I've attached the workbook
    Cheers
    Phil
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-25-2012
    Location
    Melbourne, Victoria
    MS-Off Ver
    Excel 2007
    Posts
    82

    Re: VBA Multiple Conditional Formatting

    Thank you so much for that but I think I maybe I have not explained myself properly I need it to change the row if the Word Dial and Word Booked and a Date is found all of these not just any of these. Also for each row I need to have a different colour.

    Light Blue for Dial Row
    Light Red for Install
    etc

  6. #6
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: VBA Multiple Conditional Formatting

    Hi slohman.. Try this. The reason it was colouring when it shouldn't was the hidden columns I didn't count. Fixed it now
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-25-2012
    Location
    Melbourne, Victoria
    MS-Off Ver
    Excel 2007
    Posts
    82

    Re: VBA Multiple Conditional Formatting

    Thank you Thank you Thank you

    You are brilliant that has got to be the best macro ever.

    Do you know how I can fix this little problem.
    HTML Code: 

  8. #8
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: VBA Multiple Conditional Formatting

    Sorry.. I've never tried sending emails from Excel. I'd have to learn how to do it first

  9. #9
    Registered User
    Join Date
    03-25-2012
    Location
    Melbourne, Victoria
    MS-Off Ver
    Excel 2007
    Posts
    82

    Re: VBA Multiple Conditional Formatting

    Thanks for everything. If you learn how to do it can you post me

  10. #10
    Registered User
    Join Date
    03-25-2012
    Location
    Melbourne, Victoria
    MS-Off Ver
    Excel 2007
    Posts
    82

    Re: VBA Multiple Conditional Formatting

    Works Project 2014 28032014.xlsm
    I have just tried this on my worksheet but with no luck after the initial rows.

    I have blank rows i need it to continue down each row until end.

    I also noticed that if the word booked in "F" or the date in "J" is not entered the row is still coloured I need it to colour if all 3 columns are filled "A" "F" and "J".

  11. #11
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: VBA Multiple Conditional Formatting

    I looked at your works project book & it's working as it should, including down to row 34. Did you clear all the row colours between your tests?

  12. #12
    Registered User
    Join Date
    03-25-2012
    Location
    Melbourne, Victoria
    MS-Off Ver
    Excel 2007
    Posts
    82

    Re: VBA Multiple Conditional Formatting

    If you mean did I use your Sub ResetCondFormatting yes I did all the colours disappeared but I would never clear the contents of all the rows it is a worksheet that I add to everyday.

    I then did Sub CondFormatMultiColour and it goes done to row 22 and stops the colouring.

  13. #13
    Registered User
    Join Date
    03-25-2012
    Location
    Melbourne, Victoria
    MS-Off Ver
    Excel 2007
    Posts
    82

    Re: VBA Multiple Conditional Formatting

    Thanks Phil I have figured it out.

    Thanks again for all your help. I might need you again for your expertise as I need to continue on with the rest of the colouring.

  14. #14
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: VBA Multiple Conditional Formatting

    This will fix the not going to the bottom of the sheet
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    03-25-2012
    Location
    Melbourne, Victoria
    MS-Off Ver
    Excel 2007
    Posts
    82

    Re: VBA Multiple Conditional Formatting

    Just wondering if you have any thoughts on the next macro I need or if I can add to the one you wrote CondFormatMultiColour I have set up more conditional formatting it is very similar it is =AND($J2>0,$A2="Dial before you Dig",P$1>=$J2,P$1<=$K2) would love to know how to right this into a vba. If you look at the original attachment I am trying to set up a gantt chart.

  16. #16
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: VBA Multiple Conditional Formatting

    It looks like you're going well with the conditional formatting + it would be a real mission, trying to set up what you've got set up, with a macro. It's easier to fix any errors in the conditional formatting on the sheet, than in code.

  17. #17
    Registered User
    Join Date
    03-25-2012
    Location
    Melbourne, Victoria
    MS-Off Ver
    Excel 2007
    Posts
    82

    Re: VBA Multiple Conditional Formatting

    Is there a way that I can delete all formatting from say Column P4 to BS700 like a reset formatting with your macro and then set formatting again copying all formatting from say cell P3 that would have all the conditional formatting attached. Maybe I could some how you format painter??

  18. #18
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: VBA Multiple Conditional Formatting

    I have no idea if that's possible, but my first thought is it's not. CF works from the conditions you've set on the sheet. I would think the only way to do what you're thinking of is to set the whole lot up in a macro. But don't take my word for it lol.
    The reason I put the clear formatting on the sheet is I was too lazy to keep clearing the formatting manually when I was playing with it. I didn't expect you to like it

  19. #19
    Registered User
    Join Date
    03-25-2012
    Location
    Melbourne, Victoria
    MS-Off Ver
    Excel 2007
    Posts
    82

    Re: VBA Multiple Conditional Formatting

    Ok so we are back to my best option being a macro wondering if we could write a new one base on your original that includes =AND($J2>0,$A2="Dial before you Dig",P$1>=$J2,P$1<=$K2) I have taken this statement straight from Conditional formatting. I dont know how to write this into a macro to colour certain cells if this is correct. Range being P:BS down. The cells colours would be exactly the same as the previous macro.
    Thanks

  20. #20
    Registered User
    Join Date
    03-25-2012
    Location
    Melbourne, Victoria
    MS-Off Ver
    Excel 2007
    Posts
    82

    Re: VBA Multiple Conditional Formatting

    Just wondering if someone can help with this?

  21. #21
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: VBA Multiple Conditional Formatting

    Hi Slohman.. I don't understand why you want it in a macro. If it's working as standard CF, why the extra work?

  22. #22
    Registered User
    Join Date
    03-25-2012
    Location
    Melbourne, Victoria
    MS-Off Ver
    Excel 2007
    Posts
    82

    Re: VBA Multiple Conditional Formatting

    The main reason I thought a macro would be better is I move all the rows around depending on job scheduling and it changes all the conditions and I also have to enter rows in and then that adds extra CF. So I thought each day end of or start of I would reset formatting with a macro and then run macro to check again and put CF back in.

  23. #23
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: VBA Multiple Conditional Formatting

    I've got a lot on my plate right now & haven't got the time to do a what appears to be a mission. It might be easier if you thought of another way to run the spreadsheet, as moving rows around & changing conditions with it sounds like it's over complicated. But that's only my opinion.
    You've got the macro I did with the conditional formatting, you could copy it into another module, rename it & then adapt it to suit whatever you're doing. It's a learning curve I know, but it's the best way to get exactly what you want. It's the route I took. I had to as my project was an ever changing mission & on top of that, until a couple of years ago,I hadn't done anything with spreadsheets. It was just a screen full of rectangles.
    Remember, Google/Bing are your friends

  24. #24
    Registered User
    Join Date
    03-25-2012
    Location
    Melbourne, Victoria
    MS-Off Ver
    Excel 2007
    Posts
    82

    Re: VBA Multiple Conditional Formatting

    Thanks for that I will do

+ 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. Replies: 5
    Last Post: 06-30-2016, 03:19 AM
  2. [SOLVED] Conditional Formatting based on multiple strings in multiple cells
    By lily_ruiz_06 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-27-2013, 04:23 PM
  3. Replies: 5
    Last Post: 12-28-2012, 02:06 PM
  4. Conditional formatting with multiple Ifs
    By afronight_76 in forum Excel General
    Replies: 1
    Last Post: 06-26-2012, 02:49 PM
  5. Replies: 2
    Last Post: 08-26-2010, 07:46 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