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: 114
Default Find ID Number

Hi Everybody

I found the code below on this forum and adapted it to my userfrom and it
works great no problems. However with a 26 sheet workbook it always finds the
last ID number in Column A. For example if ID number WM3898 is on Sheets
5,11,23 it will always show in the useform the info on sheet 23. Is it
possible to add a CommandButton that would find the first ID number in the
workbook then on click would find the same ID number if it is within the
workbook, e.g. WM3898 Sheet5, then Sheet11, Sheet23.

Private Sub cmdfind_Click()

Application.ScreenUpdating = False
Dim rngToSearch As Range
Dim rngFound As Range
Dim FindWhat As String
Dim Matches As Boolean
Dim sht As Worksheet

FindWhat = TextBox21.Text
Matches = False

For Each sht In Sheets
If TypeName(sht) = "Worksheet" Then
Set rngToSearch = sht.Columns("A")
Set rngFound = rngToSearch.Find(What:=FindWhat, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=False)
If Not (rngFound Is Nothing) Then
Matches = True
sht.Select
rngFound.Select
End If
End If
Next

If Matches = False Then
MsgBox "Sorry " & TextBox21 & " was not found."
Else


Me.Tb2.Text = ActiveCell.Offset(0, 2).Value
Me.Tb3.Text = ActiveCell.Offset(0, 1).Value
Me.Tb4.Text = ActiveCell.Offset(0, 4).Value
Me.Tb5.Text = ActiveCell.Offset(0, 5).Value
Me.Tb6.Text = ActiveCell.Offset(0, 6).Value
Me.Tb7.Text = ActiveCell.Offset(0, 7).Value
Me.Tb8.Text = ActiveCell.Offset(0, 8).Value
Me.Tb9.Text = ActiveCell.Offset(0, 9).Value
Me.Tb10.Text = ActiveCell.Offset(0, 10).Value

TextBox21.Value = ""

End If
Application.ScreenUpdating = True
End Sub



--
Many thanks

hazel
 
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 number of weekdays and wekend days given a total number of da Juan Correa Excel Discussion (Misc queries) 7 February 19th 10 09:47 PM
Find previous number and find next number in column DoubleZ Excel Discussion (Misc queries) 4 March 4th 09 08:51 PM
find an exact number in a different sheet and use the cell containing the number to output information [email protected] Excel Programming 4 February 18th 07 08:59 PM
countif formula to find the occurances of a number that is greater than one number but less than another steveo Excel Discussion (Misc queries) 3 July 8th 06 02:04 AM
find and delete text, find a 10-digit number and put it in a textbox Paul Excel Programming 3 November 16th 04 04:21 PM


All times are GMT +1. The time now is 01:00 PM.

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"