|
-
Sep 23rd, 2010, 06:29 AM
#1
Thread Starter
Frenzied Member
-
Sep 23rd, 2010, 06:52 AM
#2
Re: Carriage returns and Text Format
Can you upload a sample of the excel file for a quick resolution?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Sep 23rd, 2010, 06:53 AM
#3
Re: Carriage returns and Text Format
In addition some lines just appear as "#####" which I also dont know why.
generally a number longer than will display in the cell
the | is probably a vbcr (chr(13))
so you should replace vbcrlf with vblf (chr(10))
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 23rd, 2010, 07:11 AM
#4
Thread Starter
Frenzied Member
Re: Carriage returns and Text Format
Attached a workbook with the problem.
Is it worth mentioning that as the data is put into a record set before drwan onto the workbook, it may be possible to apply a fix either bofore or after the data is being displayed.
-
Sep 23rd, 2010, 07:24 AM
#5
Re: Carriage returns and Text Format
workbook missing...
You might have to zip it and then attach it...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Sep 23rd, 2010, 08:07 AM
#6
Re: Carriage returns and Text Format
1. Line-feed character:
Excel use Chr(10) = vbLf to break lines in cells. Your database such as Access uses vbCrLf = Chr(13) & Chr(10) for line-breaks.
The "bar" (with font size < 8) or a "square box" (with font size >=8) represents Chr(13) = vbCr.
* You have to remove Chr(13) in data from database before populating it to Excel.
sFieldText = Replace(sFieldText, vbCr, "")
or
sFieldText = Replace(sFieldText, vbCrLf, vbLf)
or
* After populating use this worksheet formula: =SUBSTITUTE(D2,CHAR(13),"")
2. The text is displayed as ####################################:
When a cell has been formatted as Text (with NumberFormat = "@"), if the cell contains more than 255 characters then it will be displayed like that even you make the cell very wide and/or very high.
* To fix that: Change the "NumberFormat" of the cell to "General".
-
Sep 23rd, 2010, 09:22 AM
#7
Thread Starter
Frenzied Member
Re: Carriage returns and Text Format
 Originally Posted by anhn
1. Line-feed character:
Excel use Chr(10) = vbLf to break lines in cells. Your database such as Access uses vbCrLf = Chr(13) & Chr(10) for line-breaks.
The "bar" (with font size < 8) or a "square box" (with font size >=8) represents Chr(13) = vbCr.
* You have to remove Chr(13) in data from database before populating it to Excel.
sFieldText = Replace(sFieldText, vbCr, "")
or
sFieldText = Replace(sFieldText, vbCrLf, vbLf)
or
* After populating use this worksheet formula: =SUBSTITUTE(D2,CHAR(13),"")
2. The text is displayed as ####################################:
When a cell has been formatted as Text (with NumberFormat = "@"), if the cell contains more than 255 characters then it will be displayed like that even you make the cell very wide and/or very high.
* To fix that: Change the "NumberFormat" of the cell to "General".
Thanks,
as this is for a single report I have adapted your idea to the SQL layer as below, this has removed the funny lines.
I also changed the Numberformat to General to remove the hashes.
Now I just need to provide a button which can change the sheet or range to wraptext.
REPLACE(Common.tblAudit.[parameters],Char(13),'')
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|