Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
delete blank lines in excel cell
#3
Not Solved
@Diya,

You have type the first line in the cell and press Shift+enter to get to the next line.

@QAVA
I broke my head for the past two days trying to find a solution.
The newline character in excel is recognized as some special character. I tried using split function which dint help.It goes something like this,

Code:
Str = Split(CellValue, vbnewline)

I did try many other things but nothing helped.
Finally i wrote the contents of the cell in to a text file and tried reading from it.
I am half successful in doing it.

I was able to remove the spaces between the lines but at the end of the line, some special character it getting added. I am not able to fix it.

Here is the code... hope someone will be able to fix it...
---
Code:
Dim oExcel, oWbook, oSheet

Set oExcel = CreateObject("Excel.Application")
Set oWbook = oExcel.Workbooks.Open(RelPath&"\Test.xls")
Set oSheet = oWbook.Worksheets("Sheet1")
oExcel.Visible = True

Dim CellValue

CellValue = oExcel.Cells(1,1).Value

Set objfso = CreateObject("Scripting.FileSystemObject")
objfso.CreateTextFile(RelPath&"\Test.txt")
Set objfile = objfso.OpenTextFile(RelPath&"\Test.txt",2)
objfile.WriteLine(CellValue)
objfile.Close()
Set objfile = objfso.OpenTextFile(RelPath&"\Test.txt",1)
Dim Str,Str1
Do Until objfile.AtEndOfStream
    Str1 = Trim(objfile.ReadLine)
    If Str1 <> "" Then
        Str = Str & Str1 & vbnewline
    End If
Loop

Print Str
oExcel.Cells(1,2).Value = Str
---

Hope this will help you.

Thanks,
Elango
Reply


Messages In This Thread
delete blank lines in excel cell - by QAVA - 12-06-2012, 01:02 AM
RE: delete blank lines in excel cell - by diya - 12-07-2012, 01:52 AM
RE: delete blank lines in excel cell - by elango87 - 12-07-2012, 09:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Delete Firefox history and Cookies Anupama 0 1,326 06-18-2018, 11:57 AM
Last Post: Anupama
  How import final calculated values by cell formula from Excel not the formula itself. qtped 1 4,716 01-17-2017, 04:05 PM
Last Post: sagar.raythatha
  Need to Validate Text filed is blank after clicking on the Text box balak89 3 4,549 09-13-2015, 12:06 AM
Last Post: ADITI1992
  How to delete particular mails in Gmail using QTP rajkumarsm 1 3,870 10-06-2014, 07:03 PM
Last Post: rajkumarsm
  How to delete the cookies (1000 records) akhandesh 1 2,509 09-03-2014, 09:57 AM
Last Post: vinod123

Forum Jump:


Users browsing this thread: 1 Guest(s)