 |
|
 |
|
On Fri, 29 May 2009 04:01:01 -0700, Bartosz <...@Mo2.pl
„Bartosz” pisze:
I use this code in macro:
For Each ws In Worksheets
Worksheets(ws.Name).Activate
For X = 1 To ilelinii - 1
Cells.Replace What:=strTabela(X, 1),
Replacement:=strTabela(X, 2), LookAt:=dopasowanie, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
Next X
Next ws
strTabela(X, 2) is table with texts to change and new one.
dopasowanie is xlWhole/xlPart define by user
Probably to count chages I will need another one.
Bartosz
|
|
 |
|
 |
 |
|
 |
|
On Fri, 29 May 2009 04:09:01 -0700, OssieMac <...@discussions.microsoft.com
No sure how much help you want here but here is an example of establishing
the number of replacements.
It involves counting the number of strings to be replaced before actually
making the replacements. (I don't know of any way of returning the number of
replacements from the Replace code.)
I have assumed that you can make a table of the results returned in the
variable dblNumberReplaces.
With Sheets("Sheet1")
dblNumberReplaces = WorksheetFunction _
.CountIf(.Cells, strToReplace)
.Cells.Replace What:=strToReplace, _
Replacement:=strReplacement, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
MatchCase:=True, _
SearchFormat:=False, _
ReplaceFormat:=False
End With
--
Regards,
OssieMac
|
|
 |
|
 |
 |
|
 |
|
On Fri, 29 May 2009 05:21:01 -0700, Bartosz <...@Mo2.pl
„OssieMac” pisze:
It will work fine, but only with parametr LookAt:=xlWhole, but when I use
LookAt:=xlPart count number and replaced number will be differend.
I try with:
dblNumberReplaces = WorksheetFunction.CountIf(.Cells, "*"&strToReplace&"*")
but with two strings in one cell (like Cells(x,y).Value = "strToReplace
123456 strToReplace") this cell is count as one.
Regards,
Bartosz
|
|
 |
|
 |
 |
|
 |
|
On Fri, 29 May 2009 22:11:01 -0700, OssieMac <...@discussions.microsoft.com
I don't often give up but I'm giving up on this one. I thought I might be
able to do what you want but too many other problems kept raising their ugly
head.
--
Regards,
OssieMac
> Bartosz
|
|
 |
|
 |
 |
|
 |
|
On Sun, 31 May 2009 22:45:02 -0700, Bartosz <...@Mo2.pl
"OssieMac” pisze:
Thanks anyway!
I don't want to change my macro, but I will need to do this.
I will change replace function to find in loop from Ms Help:
With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = 5
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < End If
End With
Inside this do ... loop I can cound changes in files.
Best Regards,
Bartosz
|
|
 |
|
 |
|
|