Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 328
Default macro change formatting

Help Please€¦ I am new to righting macros in visual basics. I have an excel
sheet I distribute to others. What I need is a macro that will change the
color of a cell (green) and the color of the text (red) when the information
in the cell has been changed.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default macro change formatting

How would the change take place?

Manually or by formula?

One-time change like from 1234 to 5678?

You could probably use Conditional Formatting for a one-timer for either.

=$D2<1234 and format to green colour and red font.

Or worksheet_change event code.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("A1:A100")) Is Nothing Then Exit Sub
On Error GoTo CleanUp
Application.EnableEvents = False
With Target
If .Value < "" Then
.Font.ColorIndex = 3
.Interior.ColorIndex = 10
End If
End With
CleanUp:
Application.EnableEvents = True
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code".

Copy/paste the code into that module.


Gord Dibben MS Excel MVP

On Mon, 30 Jul 2007 11:08:03 -0700, Lisa wrote:

Help Please… I am new to righting macros in visual basics. I have an excel
sheet I distribute to others. What I need is a macro that will change the
color of a cell (green) and the color of the text (red) when the information
in the cell has been changed.


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 328
Default macro change formatting

Thank you so much for the help. It works like a charm.


"Gord Dibben" wrote:

How would the change take place?

Manually or by formula?

One-time change like from 1234 to 5678?

You could probably use Conditional Formatting for a one-timer for either.

=$D2<1234 and format to green colour and red font.

Or worksheet_change event code.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("A1:A100")) Is Nothing Then Exit Sub
On Error GoTo CleanUp
Application.EnableEvents = False
With Target
If .Value < "" Then
.Font.ColorIndex = 3
.Interior.ColorIndex = 10
End If
End With
CleanUp:
Application.EnableEvents = True
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code".

Copy/paste the code into that module.


Gord Dibben MS Excel MVP

On Mon, 30 Jul 2007 11:08:03 -0700, Lisa wrote:

Help Please€¦ I am new to righting macros in visual basics. I have an excel
sheet I distribute to others. What I need is a macro that will change the
color of a cell (green) and the color of the text (red) when the information
in the cell has been changed.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel bar chart formatting of bars to change colors as data change JudyT Excel Discussion (Misc queries) 1 January 24th 07 06:07 PM
how do I change formatting of text? Marian Excel Discussion (Misc queries) 2 August 31st 06 04:05 PM
Change Formatting In 'Active' Cell JB2010 Excel Discussion (Misc queries) 4 February 2nd 06 05:58 PM
How do I change macro text with another macro? Eric Excel Discussion (Misc queries) 4 April 27th 05 11:20 PM
Date Formatting change PaulG Excel Worksheet Functions 1 January 25th 05 03:31 PM


All times are GMT +1. The time now is 10:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"