Counting Colored Cells in particular row in whole workbook

halfsparrow

New Member
Joined
Feb 23, 2021
Messages
6
Office Version
  1. 365
Platform
  1. Windows
DSC SAMPLE.xlsx
ABCDEFGHIJKL
4March 12, 2021
5Floor toRISER #RISER #
6FloorDrainS01S02
7FloorHeightSize
8No.Total Units =18Total Units =18
9MMINCHMMHWSCHWSHWRCHWRHWSCHWSHWRCHWR
10L1 
11L2 
12L3 
13L43600141.753220CST20CST20CRT20CRT
14L53600141.753240502020>2520CST20CST20CRT20CRT
15L63000118.25324050202540502020
16L73000118.253240>3250202540>32502020>25
17L83000118.2532325020>252532502025
18L93000118.253232502525>3232502025
19L103000118.25323250>402532325020>2525
20L113000118.25323240253232502525>32
21L123000118.253232402532 *3250>402532 *
22L133000118.2532324025 *32324025 *32
23L143000118.253232>2540 *2532>403240 *2532
24L153600141.753225 *40>3225>3240* 32>25402532
25L163000118.25322540>3225>3232>40
26L173000118.25322532324025323240
27L183000118.253225323240>5025323240>50
28L193000118.253225>2032>25325025>2032>253250
29L203000118.2532202532>4050202532>4050
30L213000118.25322025>2040502025>204050
31L223000118.253220CS9020CS90405020CS9020CS904050
32 
1
Cell Formulas
RangeFormula
J4J4='INPUT and Summary'!B4
G8,K8G8=COUNTA(F10:F46)*COUNTA(E6:H7)
C10:C32C10=CEILING(B10*0.0393701, 0.25)






Hello experts

I need help of a very small thing

so basically what i need help with is:

There is a userForm1 that will allow user to open the excel file they want and as soon as the open another excel file UserForm2 pops up

userform2 has a text field that allows user to enter a value.

what i want is if the user entered 7 in that value my application should search for 7 in Column A and select the whole row that has 7 and count the light blue colored cell in that particular row



For example, the excel file i have attached has only 1 sheet but the things i will be working on will have more than one sheet.

So for instance a user entered L15 in the textbox, what i want is to find the L15 in Column A and select that entire row and tell me that it has 2 light blue colored cells (i just want for the light blue and not the other colors)

if the file has more than one sheet than it need to search L28 on every sheet and give out total number of light blue colored cells in total. (like sheet 1 has 2 light blue colored cell, sheet 2 has 3, sheet 3 has 5 so it should show me L28 has 10 light blue colored cells)



RGB for that color is : RGB(189, 215, 238)



my code for userform1

name of textbox in userform2 is TextBox1

Uploaded at: Counting Colored Cells in particular row in whole workbook - OzGrid Free Excel/VBA Help Forum
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
VBA Code:
Function CountColoredCells()
    Dim sh As Worksheet
    Dim wb As Workbook
    Dim rng1 As Range, rng2 As Range, c As Range
    Dim lr As Long
    Dim f as Variant
    
    CountColoredCells = 0
    Set wb = ActiveWorkbook
    For Each sh In wb.Worksheets
        lr = sh.Range("A" & Rows.Count).End(xlUp).Row
        Set rng1 = sh.Range("A1:A" & lr)
        f = Application.Match(UserForm1.TextBox1, rng1, 0)
        If Not IsError(f) Then
            lc = sh.Cells(f, Columns.Count).End(xlToLeft).Column
            Set rng2 = sh.Range(sh.Cells(f, 1), sh.Cells(f, lc))
            For Each c In rng2
                If c.Interior.Color = RGB(189, 215, 238) Then CountColoredCells = CountColoredCells + 1
            Next
        End If
    Next
End Function
 
Upvote 0

Forum statistics

Threads
1,214,879
Messages
6,122,065
Members
449,064
Latest member
scottdog129

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top