How Do You Change The Contents Of A Cell Depending On What Is Already In That Cell

TkdKidSnake

Board Regular
Joined
Nov 27, 2012
Messages
245
Office Version
  1. 365
Platform
  1. Windows
Hi All,

does anyone know how to change the contents of a cell in a spreadsheet depending on what is found in the same cell and then change the colour scheme using VBA

For example

Cell Value = N/A#
New Cell Value Will Be = Not On Previous Report
Colour Scheme = Black & Bold Text on a yellow background

Or

Cell Value = Zero or the cell has nothing in so is blank
New Cell Value Will Be = No Update Provided On Previous Report
Colour Scheme = White & Bold Text on a red backgroud

There are also other cell values and these are to be left intact.


Thanks in advance for any help provided it is most appreciated.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
For example, for the active cell:

Code:
Sub wigi()

    With ActiveCell
    
        If .Value = CVErr(xlErrNA) Then
            .Value = "Not On Previous Report"
            .Font.Bold = True
            .Font.Color = 0
            .Interior.ColorIndex = 6
        End If
    
    End With

End Sub
 
Upvote 0
This has also been posted on the following sites

excel - Change The Contents Of A Cell Depending On What Is Already In That Cell - Stack Overflow
How Do You Change The Contents Of A Cell Depending On What Is Already In That Cell


Hi All,

does anyone know how to change the contents of a cell in a spreadsheet depending on what is found in the same cell and then change the colour scheme using VBA

For example

Cell Value = N/A#
New Cell Value Will Be = Not On Previous Report
Colour Scheme = Black & Bold Text on a yellow background

Or

Cell Value = Zero or the cell has nothing in so is blank
New Cell Value Will Be = No Update Provided On Previous Report
Colour Scheme = White & Bold Text on a red backgroud

There are also other cell values and these are to be left intact.


Thanks in advance for any help provided it is most appreciated.
 
Upvote 0
5 hours without a reply on a Sunday morning seems to necessitate cross-posting?
Posting a question on 3 forums, what?
Maybe posting at Ozgrid.com is a possibility?

Anyway, I have given an answer above. Please make sure you close the other topics asap since the question is / will be solved here.
Thanks.
 
Upvote 0
Thank you for your response, can this also be done for an array of data i.e. in a loop - my data appears in column J from cell J4 and can vary in length



For example, for the active cell:

Code:
Sub wigi()

    With ActiveCell
    
        If .Value = CVErr(xlErrNA) Then
            .Value = "Not On Previous Report"
            .Font.Bold = True
            .Font.Color = 0
            .Interior.ColorIndex = 6
        End If
    
    End With

End Sub
 
Upvote 0
Hi Wigi,

This was posted in the UK less than 30 mins ago so it must be either the server time or time difference between countries.

Apologies for the misunderstanding
 
Upvote 0
The topic at StackOverflow was created shortly, I agree.
The one at ExcelForum... not so sure. I see 6:11 AM as the time.
Even if it's all done in half an hour, why??? The kind of question you ask is usually (non-weekend days) solved in half an hour at most.
In any case, I do not agree with this kind of posting behavior, that's clear.
I see that you refuse to update the topics at StackOverflow and ExcelForum.
I will not provide any more help to you, sorry, but I bet you will understand.
 
Upvote 0

Forum statistics

Threads
1,216,545
Messages
6,131,286
Members
449,641
Latest member
paulabrink78

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