populate values in adjacent cells based on duplicates name & font color

Abdo

Board Regular
Joined
May 16, 2022
Messages
183
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Hello

I want if the values in column H is highlighted by green font color , then should show in correspond cells in column A is 0 and if the value in column H is black , then should populate in correspond cells in column A is the same value and if the column C contains duplicated names and the the adjacent cells in columns D,E are empty , then should fill empty adjacent cells as is existed from first time.
before
TEST (3).xlsx
ABCDEFGHI
2AMOUNTCOUNTNAMEINSUR NONATDATECOSTSELLINGINTEREST
31ALAA1N01548805SY7/1/202035040050
41ALAA2Q545406JO7/1/202032040080
51ALAA3A830660EG7/10/202032040080
62ALAA17/15/202035040050
73ALAA17/17/202035040050
Sheet1
Cell Formulas
RangeFormula
B3:B7B3=COUNTIF($C$3:C3,C3)
G7G7=IF($F7>0,"350",IF($F7>0,"",IF($F7<0," ","")))
I3:I7I3=H3-G3



after
TEST (3).xlsx
ABCDEFGHI
2AMOUNTCOUNTNAMEINSUR NONATDATECOSTSELLINGINTEREST
301ALAA1N01548805SY7/1/202035040050
401ALAA2Q545406JO7/1/202032040080
501ALAA3A830660EG7/10/202032040080
64002ALAA1N01548805SY7/15/202035040050
74003ALAA1N01548805SY7/17/202035040050
Sheet1
Cell Formulas
RangeFormula
B3:B7B3=COUNTIF($C$3:C3,C3)
G7G7=IF($F7>0,"350",IF($F7>0,"",IF($F7<0," ","")))
I3:I7I3=H3-G3
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
green font color come from manual color .
 
Upvote 0
Try with VBA solution (Alt-F11 to open VBA window, insert/ module. copy below code the paste into:
VBA Code:
Option Explicit
Sub test()
Dim lr&, cell As Range
lr = Cells(Rows.Count, "C").End(xlUp).Row
For Each cell In Range("A3:A" & lr)
    With cell.Offset(, 7)
        cell.Value = IIf(.Font.Color = 5287936, 0, .Value) ' 5287936: current green color found
    End With
Next
For Each cell In Range("D3:E" & lr)
    If IsEmpty(cell) Then
        cell.FormulaR1C1 = "=INDEX(R[-4]C:R[-1]C,MATCH(RC3,R[-4]C3:R[-1]C3,0))"
        cell.Value = cell.Value
    End If
Next
End Sub
 
Upvote 0
Solution
Especially if the data is large, this may have some benefit as it avoids looping through cells individually.

VBA Code:
Sub CompleteData()
  With Range("A3:I" & Range("B" & Rows.Count).End(xlUp).Row)
    .Columns(1).Value = .Columns(8).Value
    On Error Resume Next
    With .Columns(4).Resize(, 2)
      .SpecialCells(xlBlanks).FormulaR1C1 = "=INDEX(R3C:R[-1]C,MATCH(RC3,R3C3:R[-1]C3,0))"
      .Value = .Value
    End With
    .Offset(-1).Resize(.Rows.Count + 1).AutoFilter Field:=8, Criteria1:=RGB(0, 176, 80), Operator:=xlFilterFontColor
    .Columns(1).SpecialCells(xlVisible).Value = 0
    On Error GoTo 0
    .Parent.AutoFilterMode = False
  End With
End Sub
 
Upvote 0
two options are great !
thanks guys :)
 
Upvote 0
You're welcome. Glad we could help. Thanks for the follow-up. (y)
 
Upvote 0
Oops, I forgot to mention. If you are actually using the solution that you have marked, you will need to alter the formula in the vba else if would not give correct values for the blank cells in this example

Abdo_1.xlsm
BCDE
1
2COUNTNAMEINSUR NONAT
31ALAA1N01548805SY
41ALAA2Q545406JO
51ALAA3A830660EG
61ALAA4XK
71ALAA5YL
81ALAA6ZM
92ALAA1
103ALAA1
Sheet1 (8)
Cell Formulas
RangeFormula
B3:B10B3=COUNTIF($C$3:C3,C3)


I believe that the change required is

Rich (BB code):
cell.FormulaR1C1 = "=INDEX(R[-4]C:R[-1]C,MATCH(RC3,R[-4]C3:R[-1]C3,0))"
cell.FormulaR1C1 = "=INDEX(R3C:R[-1]C,MATCH(RC3,R3C3:R[-1]C3,0))"
 
Upvote 0
I want a VBA code similar, but my requirement is slightly different. I thought this thread is more suitable to ask for a solution.

Column: A is a List Value type where the cell values contains

1. Create
2. Modify
3. Activate
4. Inactivate.

Column: B is a List Value type where the cell values contains
  • New
  • Change Status
  • Add Channel
What I need is? If my user selects Col A = “Create” then in column B = New value should populate

If my user selects Col A = Modify, then in Column B Change Status & Add Channel should show in the dropdown list so that user can pick any one of the value from the list.


Col=A
Col=B
Create or modify?
Type Of Change
Create​
New​
Modify​
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

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