Vba - Excel Formula Cell Based On Background Color - Stack Overflow
Vba - Excel Formula Cell Based On Background Color - Stack Overflow
Vba - Excel Formula Cell Based On Background Color - Stack Overflow
I need a formula in EXCEL that place a number 1 in the cell next to the cell where the cell background is RED. See example below.
Not possible without VBA. Very simple with VBA... your choice – CallumDA Feb 2 '17 at 9:52
Can you give me the answer in VBA then and where to place the code? – Etienne Feb 2 '17 at 9:52
Open the VBA editor and add a new module. Do this by going to the Developer tab and clicking Visual Basic . If you don't have the
developer tab on the ribbon you will need to add it (do a quick Google search). Once the VBA editor is open, right click on the VBA
By using our site,
has you
youracknowledge that you
onhave
the read and insert
understand our Cookie Policy, Privacy Policy, and our Terms of Service.
4 project which workbook name left and a module.
https://stackoverflow.com/questions/41998676/excel-formula-cell-based-on-background-color 1/4
27/11/2020 vba - Excel Formula Cell Based on Background color - Stack Overflow
then you can use the formula =IsRed(A1) to determine if A1 has a red background
Thank you very much! Yes very easy! – Etienne Feb 2 '17 at 11:57
This can be done from Name Manager this can be accessed by pressing Ctrl + F3 .
6 You will want to create a named reference (i called this "color") and have it refer to =GET.CELL(63,OFFSET(INDIRECT("RC",FALSE),0,-1)) in
the formula bar.
Now you can use this 1 cell to the right to determine the color index number of a cell:
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.
https://stackoverflow.com/questions/41998676/excel-formula-cell-based-on-background-color 2/4
27/11/2020 vba - Excel Formula Cell Based on Background color - Stack Overflow
So as red is color index 3 in the cell next to it you can apply the formula:
=IF(color=3,1,0)
4 1. Make sure you have a title above the column with colours and above the column where you want the value 1 placed
2. Add an Autofilter (Select both columns, click the Filter button on the Data tab of the ribbon)
3. Click the drop down filter on the column with colours, then click on Filter by Colour, the choose the Red colour
4. In your second column, enter a 1 in every visible cell. (Enter 1 in the first cell, then fill down. Or, select all cells, type 1 then press
ctrl-enter)
By using our site, you acknowledge that you have read and understand our Cookieedited
Policy , Privacy
Feb 2 '17 atPolicy
10:27 , and our Terms of Service
answered Feb 2 .'17 at 10:15
https://stackoverflow.com/questions/41998676/excel-formula-cell-based-on-background-color 3/4
27/11/2020 vba - Excel Formula Cell Based on Background color - Stack Overflow
Michael
3,883 2 8 23
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.
https://stackoverflow.com/questions/41998676/excel-formula-cell-based-on-background-color 4/4