ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   enter number in cell when font color is changed (https://www.excelbanter.com/excel-discussion-misc-queries/161759-enter-number-cell-when-font-color-changed.html)

Suzi

enter number in cell when font color is changed
 
I would like a number to be automatically entered into a cell as the font
color of that cell is changed to a specific color. Any ideas? I am using
Excel 2003. I appreciate any help!

Suzi

Gord Dibben

enter number in cell when font color is changed
 
You would need VBA code to do that

Unfortunately event code won't react to a change of color so you would need a
macro which you run manually.


Gord Dibben MS Excel MVP

On Thu, 11 Oct 2007 09:25:02 -0700, Suzi wrote:

I would like a number to be automatically entered into a cell as the font
color of that cell is changed to a specific color. Any ideas? I am using
Excel 2003. I appreciate any help!

Suzi



Suzi

enter number in cell when font color is changed
 
unfortunately I am too new to Excel to know how to use macros - is how to do
this something you would share with me?

"Gord Dibben" wrote:

You would need VBA code to do that

Unfortunately event code won't react to a change of color so you would need a
macro which you run manually.


Gord Dibben MS Excel MVP

On Thu, 11 Oct 2007 09:25:02 -0700, Suzi wrote:

I would like a number to be automatically entered into a cell as the font
color of that cell is changed to a specific color. Any ideas? I am using
Excel 2003. I appreciate any help!

Suzi




Gord Dibben

enter number in cell when font color is changed
 
Can be done but do you want a choice of numbers depending upon the color?

Just one particular color and one specific number?

Just one cell or many cells?

First scenario..................

Sub test1()
Dim rng As Range
Set rng = ActiveSheet.Range("A1")
Select Case rng.Font.ColorIndex
Case Is = 3: Num = 1234 'red font
Case Is = 4: Num = 5678 'green
Case Is = 5: Num = 9876 'blue
Case Is = 6: Num = 4321 'yellow
Case Is = 7: Num = 8765 'pink
End Select
rng.Value = Num
End Sub

Second scenario...............

Sub test2()
With ActiveSheet.Range("A1")
If .Font.ColorIndex = 3 Then
.Value = 12345
End If
End With
End Sub

Since you're not familiar with VBA and macros, see David McRitchie's site for
more on "getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

First...create a backup copy of your original workbook.

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + r to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the code in there. Save the
workbook and hit ALT + Q to return to your workbook.

Run or edit the macro by going to ToolMacroMacros.

You can also assign this macro to a button or a shortcut key combo.

Another method would be a doubleclick or selectionchange event. If interested
post back with more details.


Gord

On Thu, 11 Oct 2007 13:09:03 -0700, Suzi wrote:

unfortunately I am too new to Excel to know how to use macros - is how to do
this something you would share with me?

"Gord Dibben" wrote:

You would need VBA code to do that

Unfortunately event code won't react to a change of color so you would need a
macro which you run manually.


Gord Dibben MS Excel MVP

On Thu, 11 Oct 2007 09:25:02 -0700, Suzi wrote:

I would like a number to be automatically entered into a cell as the font
color of that cell is changed to a specific color. Any ideas? I am using
Excel 2003. I appreciate any help!

Suzi






All times are GMT +1. The time now is 09:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com