VBA formating

K-R-Hattie

New Member
Joined
Feb 11, 2011
Messages
44
Hi

I am trying to format a cell using VBA, I want to enter in cell C3 "Running" and the cell to return the value 1, is this something any one can help me with?

thanks
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
I can't see what use it would be as it would be easier to just type 1 instead, anyway this goes in the worksheet code module (right click the tab of the sheet you are working with and choose "View code")
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$C$3" Then Exit Sub
If Target.Cells.Count <> 1 Then Exit Sub
If Target.Value = LCase("Running") Then
Target.Value = 1
End If
End Sub
 
Upvote 0
Hi many thanks, I haven’t explained myself, I want the value to be 1 but the word running to still show in the cell.
 
Upvote 0
Select the cell and choose cell formatting

In the wizard, pick the 'number' tab

Select 'custom' and in the 'type' box, enter the following

"Running"

Include the quotes

If you only want it to say "running" for values of 1, try:

[=1]"Running";General
 
Last edited:
Upvote 0
In VB

Code:
Sub setformat()
    Range("C3").NumberFormat = "[=1]""Running"";General"
End Sub
 
Upvote 0
I am trying to format a cell using VBA, I want to enter in cell C3 "Running" and the cell to return the value 1, is this something any one can help me with?
You have a squillion cells to play with in a worksheet - why do you want to shoehorn two things into a single cell? Why not just use two separate cells?
 
Upvote 0

Forum statistics

Threads
1,224,508
Messages
6,179,189
Members
452,893
Latest member
denay

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