Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.excel.programming > #109599 > unrolled thread

Fill Cell with Colour if Q

Started byseanryanie@yahoo.co.uk
First post2016-11-17 07:22 -0800
Last post2016-11-18 16:02 +0000
Articles 6 — 3 participants

Back to article view | Back to microsoft.public.excel.programming


Contents

  Fill Cell with Colour if Q seanryanie@yahoo.co.uk - 2016-11-17 07:22 -0800
    Re: Fill Cell with Colour if Q Claus Busch <claus_busch@t-online.de> - 2016-11-17 16:34 +0100
      Re: Fill Cell with Colour if Q seanryanie@yahoo.co.uk - 2016-11-17 07:47 -0800
        Re: Fill Cell with Colour if Q Claus Busch <claus_busch@t-online.de> - 2016-11-17 17:26 +0100
          Re: Fill Cell with Colour if Q seanryanie@yahoo.co.uk - 2016-11-17 10:45 -0800
    Re: Fill Cell with Colour if Q bulong <bulong@gmail.com> - 2016-11-18 16:02 +0000

#109599 — Fill Cell with Colour if Q

Fromseanryanie@yahoo.co.uk
Date2016-11-17 07:22 -0800
SubjectFill Cell with Colour if Q
Message-ID<86c817e5-f3c4-44bc-a475-449d0738ec27@googlegroups.com>
Is there VBA code that will fill a cell with a certain colour, say yellow, if another cell = value of any one of 5,6,100,175,101 etc

I have the array list in a Range (called 'Products) and I want to easily see these products on a Sales mix report?

So Column E contains the Product Number; Col F Contains Product Name, which I want to fill with a colour, and Col M contains Qty Sold, which I'd like also to fill with a colour

[toc] | [next] | [standalone]


#109600

FromClaus Busch <claus_busch@t-online.de>
Date2016-11-17 16:34 +0100
Message-ID<o0kikh$cfa$1@dont-email.me>
In reply to#109599
Hi Sean,

Am Thu, 17 Nov 2016 07:22:08 -0800 (PST) schrieb seanryanie@yahoo.co.uk:

> Is there VBA code that will fill a cell with a certain colour, say yellow, if another cell = value of any one of 5,6,100,175,101 etc
> 
> I have the array list in a Range (called 'Products) and I want to easily see these products on a Sales mix report?
> 
> So Column E contains the Product Number; Col F Contains Product Name, which I want to fill with a colour, and Col M contains Qty Sold, which I'd like also to fill with a colour


try:

Sub FillColor()
Dim LRow As Long
Dim rngC As Range

With ActiveSheet
    LRow = .Cells(.Rows.Count, "E").End(xlUp).Row
    For Each rngC In .Range("E2:E" & LRow)
        If Application.CountIf(Range("Products"), rngC) > 0 Then
            rngC.Offset(, 1).Interior.Color = vbYellow
            rngC.Offset(, 8).Interior.Color = vbYellow
        End If
    Next
End With
End Sub


Regards
Claus B.
-- 
Windows10
Office 2016

[toc] | [prev] | [next] | [standalone]


#109601

Fromseanryanie@yahoo.co.uk
Date2016-11-17 07:47 -0800
Message-ID<30b37c9e-3ac8-45d3-b4ec-a117e2eab435@googlegroups.com>
In reply to#109600
Fantastic Claus (again) works like a dream

[toc] | [prev] | [next] | [standalone]


#109602

FromClaus Busch <claus_busch@t-online.de>
Date2016-11-17 17:26 +0100
Message-ID<o0kln6$nv4$1@dont-email.me>
In reply to#109601
Hi Sean,

Am Thu, 17 Nov 2016 07:47:16 -0800 (PST) schrieb seanryanie@yahoo.co.uk:

> Fantastic Claus (again) works like a dream

if you have a huge amount of rows try:

Sub FillColor2()
Dim LRow As Long, i As Long
Dim varCheck As Variant, varData As Variant
Dim strCheck As String

varCheck = Range("Products")
With Application
    strCheck = Join(.Index(.Transpose(varCheck), 1, 0), ",")
End With
    
With ActiveSheet
    LRow = .Cells(.Rows.Count, "E").End(xlUp).Row
    varData = .Range("E1:E" & LRow)
    For i = LBound(varData) To UBound(varData)
        If InStr(strCheck, varData(i, 1) & ",") Then
            .Cells(i, "F").Interior.Color = vbYellow
            .Cells(i, "M").Interior.Color = vbYellow
        End If
    Next
End With
End Sub

This macro is a little bit faster


Regards
Claus B.
-- 
Windows10
Office 2016

[toc] | [prev] | [next] | [standalone]


#109603

Fromseanryanie@yahoo.co.uk
Date2016-11-17 10:45 -0800
Message-ID<1e2591e8-3d57-4c3a-bdd2-1bbcbbc15c48@googlegroups.com>
In reply to#109602
Thanks Claus, I'll have a look at that one, although with 2,500 rows the previous one did it in the blink of an eye

[toc] | [prev] | [next] | [standalone]


#109608

Frombulong <bulong@gmail.com>
Date2016-11-18 16:02 +0000
Message-ID<bulong.1274e678@excelbanter.com>
In reply to#109599
Xem thêm
_________________
'BULONG' (HTTPS://T.CO/HFFCHDEL05)
https://t.co/J2X3EPlKni




-- 
bulong

[toc] | [prev] | [standalone]


Back to top | Article view | microsoft.public.excel.programming


csiph-web