LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Find from just certain sheets in a workbook


Hi, I'm a newbie to VBA and am struggling with this bit of coding so I
would really appreciate any help! I need to be able to search just
certain worksheets in the workbook as it's important that the find does
not extend to the other worksheets. The user enters the reference
number in a textbox on "Sheet 1" and it should look through just
certain sheets only and where it finds the matching value, to make that
the active cell. I don't know what I need to add to make my coding work
here. At the moment it won't find any matches and keeps making "sheet
2" the active sheet. (for speed it only needs to search column B, from
B5 onwards, on these sheets)

Private Sub CommandButton2_Click()
On Error Resume Next
Dim Findstring As String
Dim Rng As Range
Dim mysheet As Worksheets
Findstring = TextBox1.Text
Worksheets(Array("Sheet 2", "Sheet 4", _
"Sheet 6", "Sheet 8")).Select

For Each mysheet In Worksheets

If Findstring < "" Then
Set Rng = Columns(B).Find(What:=Findstring, _
After:=Range("B5"), _
LookIn:=xlValues, _
LookAt:=x1Whole, _
MatchCase:=False).Activate
If Not Rng Is Nothing Then
Application.Goto Rng, True
Else
MsgBox "No box found"
TextBox1 = ""
End If
Else
MsgBox "Please enter the box ref"
End If
Next mysheet

End Sub


--
Blondegirl
------------------------------------------------------------------------
Blondegirl's Profile: http://www.excelforum.com/member.php...o&userid=29615
View this thread: http://www.excelforum.com/showthread...hreadid=532075

 
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
Find exact match, same workbook, different sheets dmshurley Excel Discussion (Misc queries) 2 September 19th 07 03:02 AM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Programming 6 March 29th 06 12:43 PM
Macro for filter on protected workbook that works for all sheets, no matter what sheets are named? StargateFanFromWork[_3_] Excel Programming 6 January 26th 06 06:31 PM
Find / Replace sheets vs workbook in VB Bony Pony Excel Worksheet Functions 0 December 8th 04 02:21 PM
How to find the type of Sheet in Excel.Workbook.sheets collection Raj[_7_] Excel Programming 3 December 9th 03 10:48 PM


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