Change cell font color on Worksheet_Change if cell was not blank prior

SkywardPalm

Board Regular
Joined
Oct 23, 2021
Messages
61
Office Version
  1. 365
Platform
  1. Windows
I have been trying to solve this for if a quantity cell is changed, but can't figure how to avoid if the cell was blank first. I only want to adjust the font color if the cell had a value in it prior to being changed.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim QtyCell As Range
    Set QtyCell = Cells(ActiveCell.Row, Range("Qty").Column)
    If Target.Address = QtyCell.Address Then
        'Check If QTY is Changed and adjust Font Color to Red


    End If
End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Are you manually changing these cell values, one at a time?
If so, then you should be able to the a "Worksheet_SelectionChange" event procedure to capture the existing sheet value as you select the cell (and store it in a global variable).
Then you can use that global variable in a comparison in your existing "Worksheet_Change" event procedure.
See: excel 2003 - vba - remember old cell value before change
 
Upvote 0
Solution
Are you manually changing these cell values, one at a time?
If so, then you should be able to the a "Worksheet_SelectionChange" event procedure to capture the existing sheet value as you select the cell (and store it in a global variable).
Then you can use that global variable in a comparison in your existing "Worksheet_Change" event procedure.
See: excel 2003 - vba - remember old cell value before change
I am changing the cells manually, one at a time. This method worked perfectly, had to call the global variable outside of the worksheet object but I stored it through the Worksheet_SelectionChange and could use it in Worksheet_Change. Thanks for the help!
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,144
Members
453,021
Latest member
Justyna P

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