Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Recognising Text formatted cells in code

Need some help please.

I have a Worksheet which has columns formatted into either Text or
Numeric cells.

I want to:

1) Assign a range in the worksheet (e.g. $a2:$BK2).

2) Recognise the cell format of each column in that range (e.g. whether
the column format is Text or Numerical)

3) Where the column is Text formatted, take the value of each cell in
that column and add quotation marks around the value (e.g. where the
value is MONDAY, add quotation marks around MONDAY to change it to
"MONDAY").

This is so I can save the worksheet as a .CSV file where text values
are shown in quotation marks when opened as a text file(e.g.
"DM",100000,100000,"WM2","FIRM")

Any route as long as the solution is reached will be fine.

Hope I can get some help with the complete solution or at least part of
it. Many thanks in advance.

Pini



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Recognising Text formatted cells in code

Pini,

Sub Pini()
range(a2).select
do until activecell.address="BK2"
if isnumber(activecell.value) then
else
activecell.value="""&activecell.value&"""
end if
activecell.offset(0,1).select
loop

may help

Steve
"pini35" wrote in message
...
Need some help please.

I have a Worksheet which has columns formatted into either Text or
Numeric cells.

I want to:

1) Assign a range in the worksheet (e.g. $a2:$BK2).

2) Recognise the cell format of each column in that range (e.g. whether
the column format is Text or Numerical)

3) Where the column is Text formatted, take the value of each cell in
that column and add quotation marks around the value (e.g. where the
value is MONDAY, add quotation marks around MONDAY to change it to
"MONDAY").

This is so I can save the worksheet as a .CSV file where text values
are shown in quotation marks when opened as a text file(e.g.
"DM",100000,100000,"WM2","FIRM")

Any route as long as the solution is reached will be fine.

Hope I can get some help with the complete solution or at least part of
it. Many thanks in advance.

Pini



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Recognising Text formatted cells in code

That solution won't work. If you put in quotes on each end, you will get two
sets of quotes in the csv file.

"Monday"

will be

""Monday"" in the csv file.

You will have to write out your file using VBA.

http://support.microsoft.com/default...48&Product=xlw
XL2000: Procedure to Export a Text File with Both Comma and Quote Delimiters

http://support.microsoft.com/default...96&Product=xlw
XL2002: Procedure to Export a Text File with Both Comma and Quote Delimiters

--
Regards,
Tom Ogilvy


pini35 wrote in message
...
Need some help please.

I have a Worksheet which has columns formatted into either Text or
Numeric cells.

I want to:

1) Assign a range in the worksheet (e.g. $a2:$BK2).

2) Recognise the cell format of each column in that range (e.g. whether
the column format is Text or Numerical)

3) Where the column is Text formatted, take the value of each cell in
that column and add quotation marks around the value (e.g. where the
value is MONDAY, add quotation marks around MONDAY to change it to
"MONDAY").

This is so I can save the worksheet as a .CSV file where text values
are shown in quotation marks when opened as a text file(e.g.
"DM",100000,100000,"WM2","FIRM")

Any route as long as the solution is reached will be fine.

Hope I can get some help with the complete solution or at least part of
it. Many thanks in advance.

Pini



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Recognising Text formatted cells in code

Thanks for the reply.

Tried the code, but I get a Compile Error message with *IsNumber*.

Also, does this check to see if the value is numerical or the cell
format? There will be occasions where numeric values will be
represented as text.

If there is no way around this, any other suggested scripts will be
more than welcome.

Thanks again.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Recognising Text formatted cells in code

Found the cell format code that tells you if a cell is text formatted.

*if Selection.Cells(rowcount, columncount).NumberFormat = "@"* acts on
cells that are text formatted (@ is the code for a text cell)


Thanks for all your help. The code at
http://support.microsoft.com/defaul...amp;Product=xlw was especially
helpfull. I have modified it to meet my requirements.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



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
Text in Text-formatted cells changes to ### after the 255th charac wildetudor Excel Discussion (Misc queries) 2 July 30th 09 03:20 PM
Excel copied cells not recognising date formats Limes Excel Discussion (Misc queries) 1 February 12th 07 06:33 PM
How to count the number of Excel cells with text formatted Italic phausman Excel Worksheet Functions 3 July 19th 06 04:32 PM
Pivot Table keep apart cells text that I've formatted as numbers Paulo Bevervanso Excel Worksheet Functions 2 September 21st 05 08:45 PM
Converting 'General' formatted cells to Text formatted cell using. Zahid Khan Excel Worksheet Functions 1 March 12th 05 07:13 PM


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

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

About Us

"It's about Microsoft Excel"