From: Tina on
I need a macro that will add the text -0000 at the end of whatever text is in
that current cell.

For example Cell = 75154

I need to add -0000 at the end of this so then it will be

75154-0000

I have tried all the formating stuff, but the Zipcode cell format doesnt
work.
From: Roger Govier on
Hi Tina

This event code will be activated if you double click on a cell.
If it is empty - it will ignore the cell.
If it already ends in "-0000" it will strip it off.
If not, it will add "-0000" to the existing value

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If ActiveCell = "" Then Exit Sub
If Right(ActiveCell, 5) = "-0000" Then
ActiveCell.Value = Left(ActiveCell, Len(ActiveCell) - 5)
Else
ActiveCell.Value = ActiveCell.Value & "-0000"
End If
End Sub

Copy the code above
Right click on sheet tab>View code
Paste code into white pane
Alt + F11 to return to Excel

--
Regards
Roger Govier

Tina wrote:
> I need a macro that will add the text -0000 at the end of whatever text is in
> that current cell.
>
> For example Cell = 75154
>
> I need to add -0000 at the end of this so then it will be
>
> 75154-0000
>
> I have tried all the formating stuff, but the Zipcode cell format doesnt
> work.
From: Corey on
Why use the format cell function.
Highlight the row or column of cells you want to format.
Right click and select Format Cells.
On the NUMBER Tab, click Custom.
In the Type box place:- @"-0000"
Use the {@} if text is placed int he cell or use the {#} if only numerical
values are used.

No need for a macro.

Corey....
"Tina" <Tina(a)discussions.microsoft.com> wrote in message
news:1E6DF57A-BAD8-4189-80AA-8D82F56D4D16(a)microsoft.com...
>I need a macro that will add the text -0000 at the end of whatever text is
>in
> that current cell.
>
> For example Cell = 75154
>
> I need to add -0000 at the end of this so then it will be
>
> 75154-0000
>
> I have tried all the formating stuff, but the Zipcode cell format doesnt
> work.


 | 
Pages: 1
Prev: Merging different sheets
Next: Running Sum