+ Reply to Thread
Results 1 to 3 of 3

search and replace question

  1. #1
    Gary Keramidas
    Guest

    search and replace question

    can someone explain why this code works with or without the for and next
    lines? if i take out the for and next lines, it still apears to do the
    search and replace on all lines in the worksheet

    thanks

    -------------------------------------------------

    Application.ScreenUpdating = False
    For x = LastRow To 1 Step -1

    Cells.Replace What:=""" """, Replacement:=",", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Cells.Replace What:="""", Replacement:="", LookAt:=xlPart, SearchOrder _
    :=xlByRows, MatchCase:=False, SearchFormat:=False,
    ReplaceFormat:=False

    Next x
    Columns("A:A").Select
    Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited,
    _
    TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False,
    Tab:=False, _
    Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo
    _
    :=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5,
    1), Array(6, 1)), _
    TrailingMinusNumbers:=True
    Range("A1").Select
    Columns("A:E").EntireColumn.AutoFit
    Application.ScreenUpdating = True


    --


    Gary




  2. #2
    Registered User
    Join Date
    01-28-2004
    Location
    Suffolk, England
    Posts
    4
    The statement

    Cells.Replace

    will affect all rows as 'Cells' without any parameters refers to all cells on the worksheet.

    If you want to limit the rows for the replace you could try

    Range( Cells(1,1), Cells( LastRow, 1 ) ).EntireRow.Replace

    The parameters of the Cell statement above relate to Row and Column.

    Hope that helps.

  3. #3
    Gary Keramidas
    Guest

    Re: search and replace question

    thanks for the explanation. i really don't need to change anything, as long
    as it works, i was just curious why i didn't need the for/next statements.

    --


    Gary


    "humejap" <[email protected]> wrote in
    message news:[email protected]...
    >
    > The statement
    >
    > Cells.Replace
    >
    > will affect all rows as 'Cells' without any parameters refers to all
    > cells on the worksheet.
    >
    > If you want to limit the rows for the replace you could try
    >
    > Range( Cells(1,1), Cells( LastRow, 1 ) ).EntireRow.Replace
    >
    > The parameters of the Cell statement above relate to Row and Column.
    >
    > Hope that helps.
    >
    >
    > --
    > humejap
    > ------------------------------------------------------------------------
    > humejap's Profile:
    > http://www.excelforum.com/member.php...fo&userid=5506
    > View this thread: http://www.excelforum.com/showthread...hreadid=399368
    >




+ 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