#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Count

Hello from Steved

I would like to please to take the below and add a count
to it please, meaning how many times did it do replacing,
as at the moment I have to check each worksheet. I know
for example how many it should do for example I put the
value 2202 and to replace it with value 4403, it will
find in all open workbooks 2202 in 8 different workbooks
and replace it with 4403, What I need to do is now check
each of these workbooks, if their could be a total of 8
in the input box I know it is right and that would save
me checking it.

Thankyou.


Sub ChangeAllValues2()
Dim mySht As Worksheet
Dim myBook As Workbook
Dim ReplaceWith As String
Dim ToReplace As String

ToReplace = Application.InputBox("What value to replace?")
ReplaceWith = Application.InputBox("Replace '" & _
ToReplace & "' with what other value?")

For Each myBook In Application.Workbooks
For Each mySht In myBook.Worksheets
mySht.Cells.Replace _
ToReplace, ReplaceWith, _
xlWhole
Next mySht
Next myBook

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Count

I put in some lines which you may want to use or tailor them to produce the
information you need.

Sub ChangeAllValues2()
Dim mySht As Worksheet
Dim myBook As Workbook
Dim ReplaceWith As String
Dim ToReplace As String
Dim cnt as Long, num as Long, num1 as Long

cnt = 0
ToReplace = Application.InputBox("What value to replace?")
ReplaceWith = Application.InputBox("Replace '" & _
ToReplace & "' with what other value?")

For Each myBook In Application.Workbooks
For Each mySht In myBook.Worksheets
num = Application.Countif(mySht.UsedRange,ToReplace)
mySht.Cells.Replace _
ToReplace, ReplaceWith, _
xlWhole
num1 = Application.Countif(mySht.UsedRange,ToReplace)
if num 0 then
cnt = cnt + 1
end if
if num1 < 0 and num 0 then
msgbox "Problems with " & mySht.Name
end if
Next mySht
Next myBook
msgbox cnt & " sheets were changed"
End Sub

--
Regards,
Tom Ogilvy


"Steved" wrote in message
...
Hello from Steved

I would like to please to take the below and add a count
to it please, meaning how many times did it do replacing,
as at the moment I have to check each worksheet. I know
for example how many it should do for example I put the
value 2202 and to replace it with value 4403, it will
find in all open workbooks 2202 in 8 different workbooks
and replace it with 4403, What I need to do is now check
each of these workbooks, if their could be a total of 8
in the input box I know it is right and that would save
me checking it.

Thankyou.


Sub ChangeAllValues2()
Dim mySht As Worksheet
Dim myBook As Workbook
Dim ReplaceWith As String
Dim ToReplace As String

ToReplace = Application.InputBox("What value to replace?")
ReplaceWith = Application.InputBox("Replace '" & _
ToReplace & "' with what other value?")

For Each myBook In Application.Workbooks
For Each mySht In myBook.Worksheets
mySht.Cells.Replace _
ToReplace, ReplaceWith, _
xlWhole
Next mySht
Next myBook

End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Count

Thankyou Tom.


-----Original Message-----
I put in some lines which you may want to use or tailor

them to produce the
information you need.

Sub ChangeAllValues2()
Dim mySht As Worksheet
Dim myBook As Workbook
Dim ReplaceWith As String
Dim ToReplace As String
Dim cnt as Long, num as Long, num1 as Long

cnt = 0
ToReplace = Application.InputBox("What value to

replace?")
ReplaceWith = Application.InputBox("Replace '" & _
ToReplace & "' with what other value?")

For Each myBook In Application.Workbooks
For Each mySht In myBook.Worksheets
num = Application.Countif(mySht.UsedRange,ToReplace)
mySht.Cells.Replace _
ToReplace, ReplaceWith, _
xlWhole
num1 = Application.Countif(mySht.UsedRange,ToReplace)
if num 0 then
cnt = cnt + 1
end if
if num1 < 0 and num 0 then
msgbox "Problems with " & mySht.Name
end if
Next mySht
Next myBook
msgbox cnt & " sheets were changed"
End Sub

--
Regards,
Tom Ogilvy


"Steved" wrote in

message
...
Hello from Steved

I would like to please to take the below and add a

count
to it please, meaning how many times did it do

replacing,
as at the moment I have to check each worksheet. I know
for example how many it should do for example I put the
value 2202 and to replace it with value 4403, it will
find in all open workbooks 2202 in 8 different

workbooks
and replace it with 4403, What I need to do is now

check
each of these workbooks, if their could be a total of 8
in the input box I know it is right and that would save
me checking it.

Thankyou.


Sub ChangeAllValues2()
Dim mySht As Worksheet
Dim myBook As Workbook
Dim ReplaceWith As String
Dim ToReplace As String

ToReplace = Application.InputBox("What value to

replace?")
ReplaceWith = Application.InputBox("Replace '" & _
ToReplace & "' with what other value?")

For Each myBook In Application.Workbooks
For Each mySht In myBook.Worksheets
mySht.Cells.Replace _
ToReplace, ReplaceWith, _
xlWhole
Next mySht
Next myBook

End Sub




.

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
Count Employee Work Time - Don't Double-count Overlapping Apts. J Excel Worksheet Functions 0 April 27th 07 05:52 AM
Excel 2000, count, sort a list & count totals? sunslight Excel Worksheet Functions 1 April 9th 07 05:46 PM
Count Intervals of 2 Consecutive Values in same Row and Return Count across Row Sam via OfficeKB.com Excel Worksheet Functions 6 November 29th 05 03:27 PM
Count Intervals of 2 Numeric values in same Row and Return Count across Row Sam via OfficeKB.com Excel Worksheet Functions 12 September 24th 05 10:58 PM
Count Intervals of Filtered TEXT values in Column and Return Count across a Row Sam via OfficeKB.com Excel Worksheet Functions 9 July 31st 05 03:37 AM


All times are GMT +1. The time now is 12:33 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"