Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Search two sheets simultaneously

Despite earlier help I'm still having problems with the following:

---------------------------------------------------------------
Sub Search()
'
Dim MyName As String
MyName = ActiveSheet.Range("E20").Value
Sheets("Engineers").Activate
Sheets("Engineers").Cells.Find(What:=MyName, _
LookAt:=xlPart, MatchCase:=False).Activate
End Sub
---------------------------------------------------------------

This macro currently takes the value of cell E20 in Sheet1 and searches
for this value in the 'Engineers' sheet.

However, I want the sheet to search both the engineers sheet and the
'office staff' sheets at the same time. Also, the macro currently
crashes if the name entered in E20 doesn't exist in either of the other
sheets.

Can anyone help? I should point out that I am completely new to vba!


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Search two sheets simultaneously

Sub Search()
Dim MyName As String
Dim rngF As Range, rngF2 As Range

MyName = ActiveSheet.Range("E20").Value

On Error Resume Next
Set rngF = Sheets("Engineers").Cells.Find(What:=MyName, _
LookAt:=xlPart, MatchCase:=False)
Set rngF2 = Sheets("Office Staff").Cells.Find(What:=MyName, _
LookAt:=xlPart, MatchCase:=False)
On Error GoTo 0
If Not rngF Is Nothing Then
MsgBox "Found in Engineers"
Else
MsgBox "Not Found in Engineers"
End If

If Not rngF2 Is Nothing Then
MsgBox "Found in Office Staff"
Else
MsgBox "Not Found in Office Staff"
End If

End Sub
Tested using Excel 97SR2 on Windows 98SE,

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------

Despite earlier help I'm still having problems with the following:

---------------------------------------------------------------
Sub Search()
'
Dim MyName As String
MyName = ActiveSheet.Range("E20").Value
Sheets("Engineers").Activate
Sheets("Engineers").Cells.Find(What:=MyName, _
LookAt:=xlPart, MatchCase:=False).Activate
End Sub
---------------------------------------------------------------

This macro currently takes the value of cell E20 in Sheet1 and searches
for this value in the 'Engineers' sheet.

However, I want the sheet to search both the engineers sheet and the
'office staff' sheets at the same time. Also, the macro currently
crashes if the name entered in E20 doesn't exist in either of the other
sheets.

Can anyone help? I should point out that I am completely new to vba!


---
Message posted from http://www.ExcelForum.com/


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
View sheets simultaneously? Bob Newman Excel Discussion (Misc queries) 1 October 18th 07 02:57 AM
how to duplex mulitple sheets simultaneously? smegen Excel Worksheet Functions 1 March 15th 07 09:03 PM
How do I unprotect multiple sheets simultaneously? ExcelPC Excel Discussion (Misc queries) 3 August 28th 06 11:15 PM
How can I protect several sheets in a workbook simultaneously? Fran crisp Excel Discussion (Misc queries) 1 June 20th 05 12:15 PM
How to apply the same background to many sheets simultaneously. Colin Hayes Excel Worksheet Functions 2 June 11th 05 02:47 PM


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