+ Reply to Thread
Results 1 to 8 of 8

Add conditional formatting and loop through activesheet

  1. #1
    Registered User
    Join Date
    03-20-2017
    Location
    Lancashire, England
    MS-Off Ver
    2010
    Posts
    40

    Add conditional formatting and loop through activesheet

    Hi Folks,

    I have the following code that adds some formatting to the active sheet via a macro. It compares data in column B<>E and applies the result to column G.

    Is there a way to repeat this process every 3 columns until the last used column. e.g. compare E<>H and applies it to column J
    compare H<>K and applies it to column M and so on until last column.


    Please Login or Register  to view this content.

    Many thanks
    Andy

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Add conditional formatting and loop through activesheet

    Possibly...
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-20-2017
    Location
    Lancashire, England
    MS-Off Ver
    2010
    Posts
    40

    Re: Add conditional formatting and loop through activesheet

    Hi dangelor,

    Thanks for your help. That is just what I was looking for. It works perfectly

    Thanks again
    Last edited by Andy15; 04-17-2017 at 06:47 AM.

  4. #4
    Registered User
    Join Date
    03-20-2017
    Location
    Lancashire, England
    MS-Off Ver
    2010
    Posts
    40

    Re: Add conditional formatting and loop through activesheet

    Hi dangelor,

    I have noticed that when my data gets to column AE the conditional formatting stops and I get an error

    Runtime error '5':

    Invalid procedure call or argument.

    Please Login or Register  to view this content.
    I am a little unsure of what the code is doing but have tried changing the number 64 to 84 and it does extend the range but earlier columns lose their formatting.

    Hope you can assist

  5. #5
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Add conditional formatting and loop through activesheet

    Seems columns with 2 letters broke the code. Try this instead...
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    03-20-2017
    Location
    Lancashire, England
    MS-Off Ver
    2010
    Posts
    40

    Re: Add conditional formatting and loop through activesheet

    Hi dangler,

    That has done the trick. Thank you so very much.

    I need to do a lot of learning, but with people like you providing invaluable help means I can try and work out how you did it and hopefully learn

  7. #7
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Add conditional formatting and loop through activesheet

    That's what I did... Good luck!

  8. #8
    Registered User
    Join Date
    03-20-2017
    Location
    Lancashire, England
    MS-Off Ver
    2010
    Posts
    40

    Re: Add conditional formatting and loop through activesheet

    Hi dangelor,

    Sorry to ask but if possible could you point me in the right direction with regards adding another formula to existing code.
    I have modded your code but keep getting the error "invalid procedure or call argument"


    The additional formula i have tried to add is
    =AND(E22=B22,G22<D22/1.2)

    I have added;
    Dim s3 As String
    Dim s4 As String

    s3 = Replace(rg.Offset(, 0).Address, "$", "")
    s4 = Replace(rg.Offset(, -3).Address, "$", "")

    and also this line of code
    Formula1:="=" & "AND" & "(" & s1 & "=" & s2 & "," & s3 & "<" & s4 & "/" & "1.2")


    Please Login or Register  to view this content.
    It's a little too complicated for me but with a bit of help hopefully I can get a better understanding
    Thanks for any help received

+ 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. To loop up Conditional Formatting
    By darksquare in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-09-2016, 04:23 AM
  2. [SOLVED] For loop - Conditional Formatting
    By gombi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-24-2014, 12:32 PM
  3. Loop within Conditional Formatting
    By daaronfriedman in forum Excel General
    Replies: 3
    Last Post: 01-12-2012, 10:18 AM
  4. VB Macro, FOR loop with conditional formatting
    By RMGreenlight in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-02-2010, 03:14 PM
  5. Conditional formatting in a loop
    By surya9 in forum Excel General
    Replies: 1
    Last Post: 02-19-2010, 04:09 PM
  6. Conditional Formatting in For:Next loop - won't work!!!
    By Cumberland in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-21-2006, 08:10 AM
  7. activesheet in loop
    By francois05 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2005, 08:31 AM

Tags for this Thread

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