+ Reply to Thread
Results 1 to 8 of 8

Replace characters in columns in excel

Hybrid View

  1. #1
    Registered User
    Join Date
    02-21-2006
    Posts
    15

    Replace characters in columns in excel

    I need some help in replacing carriage returns that is occuring in the excel file using vbscript.

    Anyone to guide me?

    Thanks

  2. #2
    Lonnie M.
    Guest

    Re: Replace characters in columns in excel

    Give something like this a try:

    Sub remove10()
    Dim Rng, r As Range
    'removes carriage returns from A1 down
    Set Rng = Range(Cells(1, 1), _
    Cells(ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row, 1))
    For Each r In Rng
    r.Value = Application.Substitute(Trim(CStr(r.Value)), Chr(10), "")
    Next r
    End Sub

    HTH--Lonnie M.


  3. #3
    Registered User
    Join Date
    02-21-2006
    Posts
    15
    sorry for the inconvience

    im writing in vbscript and im rather a newbie

    Set objXL = WScript.CreateObject ("Excel.Application")
    Set objWb = objXl.WorkBooks.Open(GetPath+file)

    I have objXL and objWB open..
    so how i can make use of ur code snippet to remove the carriage return in the worksheet?

    Thanks a lot

  4. #4
    Registered User
    Join Date
    02-21-2006
    Posts
    15
    is there any help?

  5. #5
    Registered User
    Join Date
    02-21-2006
    Posts
    15
    set objRange = objXL.Range("A1:I56")
    objRange.Select
    objRange.Replace Chr(10), ""


    i have manage to come out with something like this it replaces the carriage return with empty string..


    another question,
    how can i select all the range in the worksheet if there are fields in it?

  6. #6
    Norman Jones
    Guest

    Re: Replace characters in columns in excel

    Hi Moonwalker,

    Try:

    Set ObjRng = Activesheet.UsedRange


    ---
    Regards,
    Norman



    "moonwalker" <moonwalker.23rh7y_1140831001.7763@excelforum-nospam.com> wrote
    in message news:moonwalker.23rh7y_1140831001.7763@excelforum-nospam.com...
    >
    > set objRange = objXL.Range("A1:I56")
    > objRange.Select
    > objRange.Replace Chr(10), ""
    >
    >
    > i have manage to come out with something like this it replaces the
    > carriage return with empty string..
    >
    >
    > another question,
    > how can i select all the range in the worksheet if there are fields in
    > it?
    >
    >
    > --
    > moonwalker
    > ------------------------------------------------------------------------
    > moonwalker's Profile:
    > http://www.excelforum.com/member.php...o&userid=31766
    > View this thread: http://www.excelforum.com/showthread...hreadid=516190
    >




  7. #7
    Dave Peterson
    Guest

    Re: Replace characters in columns in excel

    dim objWks as object
    set objwks = objWB.worksheets(1)
    set objRange = objwks.usedrange
    'or set objRange = objwks.Cells
    'you don't need to select it.
    objRange.Replace Chr(10), ""

    ====
    I'm not sure what "if there are fields in it" means???


    moonwalker wrote:
    >
    > set objRange = objXL.Range("A1:I56")
    > objRange.Select
    > objRange.Replace Chr(10), ""
    >
    > i have manage to come out with something like this it replaces the
    > carriage return with empty string..
    >
    > another question,
    > how can i select all the range in the worksheet if there are fields in
    > it?
    >
    > --
    > moonwalker
    > ------------------------------------------------------------------------
    > moonwalker's Profile: http://www.excelforum.com/member.php...o&userid=31766
    > View this thread: http://www.excelforum.com/showthread...hreadid=516190


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1