VBA to find cell with a certain value and format it

jaywrye

New Member
Joined
May 6, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I have 2 pages, one in the form of a list (Sheet1) and another one in the form of a calendar format (Sheet2). I want to create a code that can help me to locate the name of the assignment taken from Sheet 1 on Sheet 2. If the assignment exists on Sheet2, check for the status of the assignment. If it is "Completed", I want the name of the Assignment on Sheet 2 to be colored in green and if it is "Pending", then the name of the assignment will be in red. Does anyone have any idea on how I can get about doing this? I will illustrate the steps below with pictures.

1620286012450.png
This is sheet 1. Here, I will have a list of assignments that will be populated in Sheet 2 based on the dates I have specified.
1620286272201.png
This is sheet 2. What I want to do here is to loop through every cell within the range of the calender (B7:H17) and match it against the list of assignments I have created in Sheet1. If the Assignment exists, then check for the status of the assignment and update the color for the assignment correspondingly.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi & welcome to MrExcel.
Does sheet 2 have formulae to return the assignments & when there are 2 or more are the concatenated together in the same cell?
 
Upvote 0
Yes there is. I use this formulae:
Excel Formula:
=IFERROR(TEXTJOIN(", ", TRUE, IF(Assignments[DUE DATE] = 'Month View'!B46, Assignments[DESCRIPTION], "")), "")
 
Upvote 0
In that case you will not be able to do it. You could use conditional formatting to change the font colour, but that works on the entire cell.
Even with VBA you would only be able to change the colour for the entire cell as it has a formula.
 
Upvote 0
Oh, if I were to transfer the formula for the cells into VBA and perform the formatting in VBA instead, will that be workable?
 
Upvote 0
To have two assignments different colour in the same cell you would need to get rid of the formula.
 
Upvote 0
Hmm I see ok I will try to think of another way to do this. Thanks for your help Fluff
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,790
Messages
6,121,607
Members
449,037
Latest member
Arbind kumar

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