+ Reply to Thread
Results 1 to 7 of 7

Formatting Issue

Hybrid View

  1. #1
    Registered User
    Join Date
    10-01-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    64

    Formatting Issue

    Hi,

    So I have a template that has a piece of formatting code which I obtained from a different post in this forum. It alternates gray & white on a copy of a pivot table to make it easier to read. Normally there are 5 different Sample Names per grouping but in this one example the user only had 3 so my formatting is off in the end. Would it be possible to get some help with this code to make it more dynamic. I would like that this modified piece of code can either get the number by input from the user or that it can get the number on its own (by maybe counting Vial rows or when there is a repeat in Sample Name) and create the correct formatting no matter how many the user may do? Please advise....

    Thank you so much for your assistance.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Formatting Issue

    Use this CF formula to alternate on\off for each change in column A

    =COUNTA($A$5:$A5)/2=INT(COUNTA($A$5:$A5)/2)
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    10-01-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    64

    Re: Formatting Issue

    I'm not sure I understand. Where do I put this code? Should it replace the formula I have there for calculating or add to it? Please advise....

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Formatting Issue

    On sheet RRT Pivoted Data, you already have conditional formatting setup to alternate color every 5th row using this CF formula
    =MOD(ROW()-5,5*2)+1<=5
    That conditional formatting is not part of your current macro, but it does copy over when you copy the data.

    Change that formula to this formula to alternate color for each change in column A
    =AND(COUNTA($A$5:$A5)/2=INT(COUNTA($A$5:$A5)/2), $B5<>"")

  5. #5
    Registered User
    Join Date
    10-01-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    64

    Re: Formatting Issue

    OK now I understand and wanted to say that that CF Formula gets put there by MyFormat piece of code, that runs along with others when the user clicks on the button on the Paste Rentention Data Tab, I never put it there. I have gone in to that CF formula and changed it to what you indicated and then applied it but it's still off. So my next question is if the user presses the button to run all the macros again will it over ride that formula or will it create another? And which CF will then take precedence? Here is the file again with the CF formula changed to what you told me.
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Formatting Issue

    This will clear previous CF formulas and add the new one.

    Sub MyFormat()
        
        Dim rngMyRange As Range
        
        Set rngMyRange = Range("A5", Cells(Cells(Rows.Count, 2).End(xlUp).Row, Cells(4, Columns.Count).End(xlToLeft).Column))    'Set your range here
        rngMyRange.Select
        rngMyRange.FormatConditions.Delete
        With rngMyRange
            .FormatConditions.Add Type:=xlExpression, Formula1:="=AND(COUNTA($A$5:$A5)/2=INT(COUNTA($A$5:$A5)/2), $B5<>"""")"
            With .FormatConditions(1).Interior
                .PatternColorIndex = xlAutomatic
                .ColorIndex = 15
            End With
        End With
        
    End Sub

  7. #7
    Registered User
    Join Date
    10-01-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    64

    Re: Formatting Issue

    Thank you soo much, that did it and it's working great!

+ 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] Possible Formatting Issue
    By cubsaredue in forum Excel General
    Replies: 4
    Last Post: 01-22-2016, 06:13 PM
  2. [SOLVED] Formatting Issue
    By rizmomin in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-12-2016, 09:49 AM
  3. [SOLVED] issue with formatting
    By MATT.B in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-16-2015, 09:12 AM
  4. Custom formatting issue using conditional formatting
    By wrongway15 in forum Excel General
    Replies: 2
    Last Post: 07-13-2014, 03:18 PM
  5. [SOLVED] #Value! due to formatting issue
    By uhlabomber in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-16-2013, 01:44 PM
  6. Formatting Issue
    By rolltyde12 in forum Excel General
    Replies: 1
    Last Post: 03-20-2007, 04:20 PM
  7. Formatting Issue
    By wayliff in forum Excel General
    Replies: 7
    Last Post: 04-13-2006, 10:47 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