Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default vba searching for strings in multiple worksheets

Hi,

I am trying to search multiple worksheets for the word "Fail" and then
copy all of the "fail" data that has a failure into another worksheet.
I am able to copy one sheet to another, but cannot figure out how to
search multiple sheets.

The number of worksheets are dynamic. The user can add sheets to the
workbook.

Here is my working code for one sheet:

With Sheet2
For i = 1 To .UsedRange.Rows.Count

If .Cells(i, 1) = "Fail" Then

'Offset to select the testcase number
Sheet1.Cells(j, 3) = Sheet2.Cells(i, 2)

'Offset to select the Serial Number
Sheet1.Cells(j, 2) = Sheet2.Cells(i, 4)

j = j + 1

Else
Sheet1.range("B15:c500") = ""

End If
Next
End With

Thank you

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default vba searching for strings in multiple worksheets

Maybe...

dim wks as worksheet
for each wks in activeworkbook.worksheets
if lcase(wks.codename) = lcase("sheet1") then
'skip this sheet
else
With wks
For i = 1 To .UsedRange.Rows.Count
If .Cells(i, 1) = "Fail" Then
'Offset to select the testcase number
Sheet1.Cells(j, 3) = .Cells(i, 2)

'Offset to select the Serial Number
Sheet1.Cells(j, 2) = .Cells(i, 4)

j = j + 1

Else
'still want to do this???
Sheet1.range("B15:c500") = ""
End If
Next i
End With
end if
next wks

(untested, uncompiled. Watch for typos!)

wrote:

Hi,

I am trying to search multiple worksheets for the word "Fail" and then
copy all of the "fail" data that has a failure into another worksheet.
I am able to copy one sheet to another, but cannot figure out how to
search multiple sheets.

The number of worksheets are dynamic. The user can add sheets to the
workbook.

Here is my working code for one sheet:

With Sheet2
For i = 1 To .UsedRange.Rows.Count

If .Cells(i, 1) = "Fail" Then

'Offset to select the testcase number
Sheet1.Cells(j, 3) = Sheet2.Cells(i, 2)

'Offset to select the Serial Number
Sheet1.Cells(j, 2) = Sheet2.Cells(i, 4)

j = j + 1

Else
Sheet1.range("B15:c500") = ""

End If
Next
End With

Thank you


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default vba searching for strings in multiple worksheets


Hi Justin

See attached document
every "Fail" should be stored in worksheet "Fail_Workbook"

Thanks
Denis


+-------------------------------------------------------------------+
|Filename: Book2.zip |
|Download: http://www.excelforum.com/attachment.php?postid=5108 |
+-------------------------------------------------------------------+

--
jetted
------------------------------------------------------------------------
jetted's Profile: http://www.excelforum.com/member.php...o&userid=17532
View this thread: http://www.excelforum.com/showthread...hreadid=565152

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 in Multiple Worksheets Lizz45ie Excel Discussion (Misc queries) 0 October 19th 05 05:22 PM
SUMif or SUMproduct across multiple worksheets? Eric Shamlin Excel Worksheet Functions 1 September 29th 05 09:55 AM
Line chart from multiple worksheets Paul B. Charts and Charting in Excel 2 September 21st 05 11:46 PM
Update multiple worksheets Lizz45ie Excel Discussion (Misc queries) 0 May 31st 05 09:21 PM
Countif with multiple criteria and multiple worksheets JJ Excel Worksheet Functions 1 December 28th 04 06:37 PM


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