+ Reply to Thread
Results 1 to 10 of 10

Highlight yellow on stock gaps

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,617

    Highlight yellow on stock gaps

    Highlight yellow where stock is Zero
    While stock on others on the same line are greather than Zero

    In the Attached file I have done those manually

    Macro to read data at 25,ooo rows

    If the rest of the Zero can be pink , It will be good ,
    Since Conditional formatting not doing that because some
    of Zero Stock is in Yellow
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,945

    Re: Highlight yellow on stock gaps

    Use this:

    Option Explicit
    
    Sub ZeroPink()
        Dim c As Range
        Dim rng As Range
        Dim lr As Long, lc As Long
        lr = Range("A" & Rows.Count).End(xlUp).Row
        lc = Cells(1, Columns.Count).End(xlToLeft).Column
        Set rng = Range(Cells(2, 2), Cells(lr, lc))
        
        Application.ScreenUpdating = False
        For Each c In rng
        If c = 0 And c <> "" And c.Interior.ColorIndex <> 6 Then
        c.Interior.ColorIndex = 22
        End If
        Next c
        Application.ScreenUpdating = True
    End Sub
    Last edited by alansidman; 11-07-2015 at 11:48 AM.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,617

    Re: Highlight yellow on stock gaps

    Expecting following cells to be Yellow

    06
    L14
    S16
    L19
    S26
    E35
    E37
    E38
    E39
    O36
    O38
    040

  4. #4
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,617

    Re: Highlight yellow on stock gaps

    Alansidman , thank you almost

    Half way through , remaining yellow highlights on stock
    where is 0 if stock in same line exists

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,945

    Re: Highlight yellow on stock gaps

    I have amended the code. If I understood correctly, where yellow, stays yellow.

  6. #6
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,617

    Re: Highlight yellow on stock gaps

    No Yellow needs to be done by macro

    It will be long to do that for 10,000 rows , one by one

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,945

    Re: Highlight yellow on stock gaps

    I'm not sure I understand the rationale/criteria for the yellow highlights.

  8. #8
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,617

    Re: Highlight yellow on stock gaps

    I am leaving the thread open , for someone to add on your macro the half of the program

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Highlight yellow on stock gaps

    Hi makinmomb

    I have no idea how fast this Code will run on 10's of Thousands of records but it appears to do as you require. Ctrl + x will fire the Code.

    Option Explicit
    
    Sub Find_Yellow()
       Dim ws           As Worksheet
       Dim Rng          As Range
       Dim cel          As Range
       Dim LR           As Long
       Dim myTot        As Long
       Dim sp           As Variant
       Dim x            As Long
       Dim y            As Long
       Dim i            As Long
       Dim j            As Long
    
       Application.ScreenUpdating = False
       Set ws = Sheets("Sheet1")
       With ws
          .Cells.Interior.ColorIndex = 0
          LR = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
                           SearchDirection:=xlPrevious).Row
          .Range("B2:W" & LR).Select
          Selection.SpecialCells(xlCellTypeConstants, 23).Select
          For i = 1 To Selection.Areas.Count
             sp = Split(Replace(Selection.Areas(i).Address, ":", ""), "$")
             x = sp(2)
             y = sp(4)
             If Not x = y Then
                For j = 2 To 23
                   myTot = WorksheetFunction.Sum(.Range(.Cells(x, j), .Cells(y, j)))
                   If myTot >= 1 Then
                      Set Rng = .Range(.Cells(x, j), .Cells(y, j))
                      For Each cel In Rng
                         If cel.Value = 0 Then
                            cel.Interior.ColorIndex = 6
                         End If
                      Next cel
                   End If
                Next j
             End If
          Next i
          For Each cel In Selection
             If cel.Interior.ColorIndex <> 6 Then
                cel.Interior.ColorIndex = 22
             End If
          Next cel
       End With
       Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  10. #10
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,617

    Re: Highlight yellow on stock gaps

    Thank you very much Jaslake ,
    I have 6o,ooo rows to work on
    I tested the data on 1000 rows , and working , wow , as exactly the way I want it

+ 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] conditional format (Highlight cell Yellow)
    By cadone in forum Excel General
    Replies: 8
    Last Post: 10-15-2014, 03:24 PM
  2. [SOLVED] Find number and highlight in yellow
    By Jerry HKA in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 02-10-2014, 04:17 AM
  3. [SOLVED] find last empty cell and highlight yellow
    By James__S in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-06-2014, 03:46 PM
  4. [SOLVED] Highlight Yellow Active Row, PROBLEM: row selected before closing stays yellow
    By NumberCruncher311 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-12-2013, 07:01 PM
  5. Highlight blank cells in yellow.
    By n_lindsey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2013, 02:17 AM
  6. Macro To find match Value from other clomn and highlight in yellow
    By tariqnaz2005 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2012, 09:42 AM
  7. Find gaps in stock data
    By Test123Test in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-18-2012, 01:38 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