Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to change a number to text

I'm having trouble trying to get this done. Just
recording the keystrokes to put in the apostrophe isn't
working. Is there a statement to be used in the macro to
accomplish this?

Thanks in advance,
Lori
-----Original Message-----
Have the Macro add an apostrophe before the number. This
will change it to text.


-----Original Message-----
Help, please?

I have a user who has a column of accts payable numbers
and a total at the bottom (=Sum). When a payment is

made,
she wants to be able to bold a number and tell Excel not
to include it in the total at the bottom.

I've created a macro to bold the current cell and format
it as text instead of a number. The cell that is now

text
should not be calculated the function, but it is. What

am
I doing wrong?

Thanks!
.

.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Macro to change a number to text

Hi Lori,

The following code will put a ' before each value in the selected cells:

Sub MakeText()
Dim rng As Range

For Each rng In Selection
With rng
.Value = "'" & CStr(.Value)
End With
Next rng
End Sub

Keep in mind that this will destroy formulas, so it should only be used on
cells that don't contain formulas. Here's how you can help protect against
that:

Sub MakeText()
Dim rng As Range

For Each rng In Selection
With rng
If Not .HasFormula Then .Value = "'" & CStr(.Value)
End With
Next rng
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Lori F wrote:
I'm having trouble trying to get this done. Just
recording the keystrokes to put in the apostrophe isn't
working. Is there a statement to be used in the macro to
accomplish this?

Thanks in advance,
Lori
-----Original Message-----
Have the Macro add an apostrophe before the number. This
will change it to text.


-----Original Message-----
Help, please?

I have a user who has a column of accts payable numbers
and a total at the bottom (=Sum). When a payment is made,
she wants to be able to bold a number and tell Excel not
to include it in the total at the bottom.

I've created a macro to bold the current cell and format
it as text instead of a number. The cell that is now text
should not be calculated the function, but it is. What am
I doing wrong?

Thanks!
.

.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default Macro to change a number to text

cell = "'" & cell.text

that's double quote, single quote, double quote

There are other ways, but this was the way you asked the question.

--
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Lori F" wrote in message ...
I'm having trouble trying to get this done. Just
recording the keystrokes to put in the apostrophe isn't
working. Is there a statement to be used in the macro to
accomplish this?

Thanks in advance,
Lori
-----Original Message-----
Have the Macro add an apostrophe before the number. This
will change it to text.


-----Original Message-----
Help, please?

I have a user who has a column of accts payable numbers
and a total at the bottom (=Sum). When a payment is

made,
she wants to be able to bold a number and tell Excel not
to include it in the total at the bottom.

I've created a macro to bold the current cell and format
it as text instead of a number. The cell that is now

text
should not be calculated the function, but it is. What

am
I doing wrong?

Thanks!
.

.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro to change a number to text

Thank you again, Jake! I'm not worried about the
formulas - the macro will only be used on raw data.

Lori
-----Original Message-----
Hi Lori,

The following code will put a ' before each value in the

selected cells:

Sub MakeText()
Dim rng As Range

For Each rng In Selection
With rng
.Value = "'" & CStr(.Value)
End With
Next rng
End Sub

Keep in mind that this will destroy formulas, so it

should only be used on
cells that don't contain formulas. Here's how you can

help protect against
that:

Sub MakeText()
Dim rng As Range

For Each rng In Selection
With rng
If Not .HasFormula Then .Value = "'" &

CStr(.Value)
End With
Next rng
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address

unmonitored]


Lori F wrote:
I'm having trouble trying to get this done. Just
recording the keystrokes to put in the apostrophe isn't
working. Is there a statement to be used in the macro to
accomplish this?

Thanks in advance,
Lori
-----Original Message-----
Have the Macro add an apostrophe before the number.

This
will change it to text.


-----Original Message-----
Help, please?

I have a user who has a column of accts payable

numbers
and a total at the bottom (=Sum). When a payment is

made,
she wants to be able to bold a number and tell Excel

not
to include it in the total at the bottom.

I've created a macro to bold the current cell and

format
it as text instead of a number. The cell that is now

text
should not be calculated the function, but it is.

What am
I doing wrong?

Thanks!
.

.


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro to change a number to text

Thank you so much, David! That should help a lot.

Lori
-----Original Message-----
cell = "'" & cell.text

that's double quote, single quote, double quote

There are other ways, but this was the way you asked the

question.

--
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed

Nov. 2001]
My Excel Pages:

http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page:

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

"Lori F" wrote in

message ...
I'm having trouble trying to get this done. Just
recording the keystrokes to put in the apostrophe isn't
working. Is there a statement to be used in the macro to
accomplish this?

Thanks in advance,
Lori
-----Original Message-----
Have the Macro add an apostrophe before the number.

This
will change it to text.


-----Original Message-----
Help, please?

I have a user who has a column of accts payable

numbers
and a total at the bottom (=Sum). When a payment is

made,
she wants to be able to bold a number and tell Excel

not
to include it in the total at the bottom.

I've created a macro to bold the current cell and

format
it as text instead of a number. The cell that is now

text
should not be calculated the function, but it is. What

am
I doing wrong?

Thanks!
.

.



.

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
Formula to change scientific number to regular number or text Compare Values Excel Discussion (Misc queries) 2 August 23rd 07 06:10 PM
Change number format from text to number? Scot New Users to Excel 2 December 1st 05 04:15 PM
Change Text to a number Brooks W. Excel Worksheet Functions 1 April 28th 05 05:20 AM
EZ Q 4 U: How do I change a number to text, based on the number UCD GRAD Excel Worksheet Functions 2 November 9th 04 09:05 PM
Macro to change a number to text Jake Marx[_3_] Excel Programming 1 November 11th 03 04:34 PM


All times are GMT +1. The time now is 03:24 PM.

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"