Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default search and replace question


The statement

Cells.Replace

will affect all rows as 'Cells' without any parameters refers to al
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

--
humeja
-----------------------------------------------------------------------
humejap's Profile: http://www.excelforum.com/member.php...nfo&userid=550
View this thread: http://www.excelforum.com/showthread.php?threadid=39936

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default 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" wrote in
message ...

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
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
Search and Replace Rebecca New Users to Excel 2 June 5th 06 06:42 AM
Search and Replace Question Rebecca New Users to Excel 1 April 11th 05 04:49 AM
Simple Search and Replace Question Rebecca Excel Discussion (Misc queries) 2 April 3rd 05 03:33 PM
Search and Replace... Paul B[_7_] Excel Programming 0 October 1st 03 06:12 PM
Macro search replace question WDP[_2_] Excel Programming 1 August 28th 03 06:18 AM


All times are GMT +1. The time now is 02:51 AM.

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

About Us

"It's about Microsoft Excel"