Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Loop Through All Open Workbooks

I'm trying to find an example of looping through all open workbooks and
doing a simple search of all cells to determine if a certain value exists in
any of the workbooks.

Any help?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Loop Through All Open Workbooks

Dim bk as Workbook, sh as Worksheet
Dim rng as Range, ans as long
for each bk in application.Workbooks
for each sh in bk.Worksheets
set rng = sh.cells.Find("string")
if not rng is nothing then
msgbox "Found at " & rng.Address(external:=True)
ans = msgbox "Continue to search",vbYesNo
if ans = vbNo then exit sub
end if
Next
Next

--
Regards,
Tom Ogilvy

"scott" wrote in message
...
I'm trying to find an example of looping through all open workbooks and
doing a simple search of all cells to determine if a certain value exists

in
any of the workbooks.

Any help?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Loop Through All Open Workbooks

Thank you again for saving sanity.

"Tom Ogilvy" wrote in message
...
Dim bk as Workbook, sh as Worksheet
Dim rng as Range, ans as long
for each bk in application.Workbooks
for each sh in bk.Worksheets
set rng = sh.cells.Find("string")
if not rng is nothing then
msgbox "Found at " & rng.Address(external:=True)
ans = msgbox "Continue to search",vbYesNo
if ans = vbNo then exit sub
end if
Next
Next

--
Regards,
Tom Ogilvy

"scott" wrote in message
...
I'm trying to find an example of looping through all open workbooks and
doing a simple search of all cells to determine if a certain value exists

in
any of the workbooks.

Any help?






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Loop Through All Open Workbooks

tom, can you look at the line

ans = msgbox "Continue to search",vbYesNo

it has a syntax error. thanks


"Tom Ogilvy" wrote in message
...
Dim bk as Workbook, sh as Worksheet
Dim rng as Range, ans as long
for each bk in application.Workbooks
for each sh in bk.Worksheets
set rng = sh.cells.Find("string")
if not rng is nothing then
msgbox "Found at " & rng.Address(external:=True)
ans = msgbox "Continue to search",vbYesNo
if ans = vbNo then exit sub
end if
Next
Next

--
Regards,
Tom Ogilvy

"scott" wrote in message
...
I'm trying to find an example of looping through all open workbooks and
doing a simple search of all cells to determine if a certain value exists

in
any of the workbooks.

Any help?






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Loop Through All Open Workbooks

ans = msgbox( "Continue to search",vbYesNo)


--

HTH

RP
(remove nothere from the email address if mailing direct)


"scott" wrote in message
...
tom, can you look at the line

ans = msgbox "Continue to search",vbYesNo

it has a syntax error. thanks


"Tom Ogilvy" wrote in message
...
Dim bk as Workbook, sh as Worksheet
Dim rng as Range, ans as long
for each bk in application.Workbooks
for each sh in bk.Worksheets
set rng = sh.cells.Find("string")
if not rng is nothing then
msgbox "Found at " & rng.Address(external:=True)
ans = msgbox "Continue to search",vbYesNo
if ans = vbNo then exit sub
end if
Next
Next

--
Regards,
Tom Ogilvy

"scott" wrote in message
...
I'm trying to find an example of looping through all open workbooks and
doing a simple search of all cells to determine if a certain value

exists
in
any of the workbooks.

Any help?










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Loop Through All Open Workbooks

ans = msgbox( "Continue to search",vbYesNo)

--
regards,
Tom Ogilvy

"scott" wrote in message
...
tom, can you look at the line

ans = msgbox "Continue to search",vbYesNo

it has a syntax error. thanks


"Tom Ogilvy" wrote in message
...
Dim bk as Workbook, sh as Worksheet
Dim rng as Range, ans as long
for each bk in application.Workbooks
for each sh in bk.Worksheets
set rng = sh.cells.Find("string")
if not rng is nothing then
msgbox "Found at " & rng.Address(external:=True)
ans = msgbox "Continue to search",vbYesNo
if ans = vbNo then exit sub
end if
Next
Next

--
Regards,
Tom Ogilvy

"scott" wrote in message
...
I'm trying to find an example of looping through all open workbooks and
doing a simple search of all cells to determine if a certain value

exists
in
any of the workbooks.

Any help?








  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Loop Through All Open Workbooks


For Each wb In Application.Workbooks
If Application.CountIf(wb.Worksheets(1).Cells,"myValu e) 1 Then
MsgBox "Found in " & wb.Name
End If
Next wb

--

HTH

RP
(remove nothere from the email address if mailing direct)


"scott" wrote in message
...
I'm trying to find an example of looping through all open workbooks and
doing a simple search of all cells to determine if a certain value exists

in
any of the workbooks.

Any help?




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Loop Through All Open Workbooks

can you correct syntax error in line

If Application.CountIf(wb.Worksheets(1).Cells,"myValu e) 1 Then


thanks

"Bob Phillips" wrote in message
...

For Each wb In Application.Workbooks
If Application.CountIf(wb.Worksheets(1).Cells,"myValu e) 1 Then
MsgBox "Found in " & wb.Name
End If
Next wb

--

HTH

RP
(remove nothere from the email address if mailing direct)


"scott" wrote in message
...
I'm trying to find an example of looping through all open workbooks and
doing a simple search of all cells to determine if a certain value exists

in
any of the workbooks.

Any help?






  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Loop Through All Open Workbooks

If Application.CountIf(wb.Worksheets(1).Cells,"myValu e") 1 Then

--
Regards,
Tom Ogilvy


"scott" wrote in message
...
can you correct syntax error in line

If Application.CountIf(wb.Worksheets(1).Cells,"myValu e) 1 Then


thanks

"Bob Phillips" wrote in message
...

For Each wb In Application.Workbooks
If Application.CountIf(wb.Worksheets(1).Cells,"myValu e) 1 Then
MsgBox "Found in " & wb.Name
End If
Next wb

--

HTH

RP
(remove nothere from the email address if mailing direct)


"scott" wrote in message
...
I'm trying to find an example of looping through all open workbooks and
doing a simple search of all cells to determine if a certain value

exists
in
any of the workbooks.

Any help?








  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Loop Through All Open Workbooks

If Application.CountIf(wb.Worksheets(1).Cells,"myValu e") 1 Then


--

HTH

RP
(remove nothere from the email address if mailing direct)


"scott" wrote in message
...
can you correct syntax error in line

If Application.CountIf(wb.Worksheets(1).Cells,"myValu e) 1 Then


thanks

"Bob Phillips" wrote in message
...

For Each wb In Application.Workbooks
If Application.CountIf(wb.Worksheets(1).Cells,"myValu e) 1 Then
MsgBox "Found in " & wb.Name
End If
Next wb

--

HTH

RP
(remove nothere from the email address if mailing direct)


"scott" wrote in message
...
I'm trying to find an example of looping through all open workbooks and
doing a simple search of all cells to determine if a certain value

exists
in
any of the workbooks.

Any help?










  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Loop Through All Open Workbooks

i ran your code and it doesn't find a particular cell or give any error. can
you try again?


"Bob Phillips" wrote in message
...

For Each wb In Application.Workbooks
If Application.CountIf(wb.Worksheets(1).Cells,"myValu e) 1 Then
MsgBox "Found in " & wb.Name
End If
Next wb

--

HTH

RP
(remove nothere from the email address if mailing direct)


"scott" wrote in message
...
I'm trying to find an example of looping through all open workbooks and
doing a simple search of all cells to determine if a certain value exists

in
any of the workbooks.

Any help?






  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Loop Through All Open Workbooks

You have a solution that does that.

--
Regards,
Tom Ogilvy

"scott" wrote in message
...
i ran your code and it doesn't find a particular cell or give any error.

can
you try again?


"Bob Phillips" wrote in message
...

For Each wb In Application.Workbooks
If Application.CountIf(wb.Worksheets(1).Cells,"myValu e) 1 Then
MsgBox "Found in " & wb.Name
End If
Next wb

--

HTH

RP
(remove nothere from the email address if mailing direct)


"scott" wrote in message
...
I'm trying to find an example of looping through all open workbooks and
doing a simple search of all cells to determine if a certain value

exists
in
any of the workbooks.

Any help?








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
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed Frank Jones Excel Programming 2 June 15th 04 03:21 AM
Loop through all Open workbooks Stuart[_5_] Excel Programming 3 June 7th 04 08:07 PM
Loop through open workbooks Bob Phillips[_6_] Excel Programming 2 April 28th 04 09:28 AM
IF wokkbook1 is open, open workbook2 Loop Fio[_2_] Excel Programming 1 March 5th 04 01:10 PM
Can I have a loop to open a set of workbooks get some data, close it one a time. wellie Excel Programming 2 July 9th 03 04:58 AM


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

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

About Us

"It's about Microsoft Excel"