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: 33
Default Using same code for Multiple cmd Controls

Hello,

I have 12 identical Worksheets, each with a Text Box and Command Button
control for Finding clients in Column 2. I would like each Command Button to
activate the same code.

In the "Module" code window, I have the following -

Public Sub Find_Name(sht As Worksheet)
Dim sRange As Range, myRange As Range
Dim searchString As String

searchString = txtFind.Value

With sht
Set sRange = .UsedRange.Columns(2)
Set myRange = sRange.Find(searchString, LookIn:=xlValues,
MatchCase:=False)

' If found select matching cell
If Not myRange Is Nothing Then
myRange.Select
MsgBox "Found Match"
Else
MsgBox "Name Not Found"
End If

End With
End Sub


In each Sheet code window I have the following, with the number representing
the Month.

' Worksheet for June
Private Sub cmdFind6_Click()

Find_Name ActiveSheet, txtFind6.Value

End Sub


I am not sure why this does not work. Please help.
Ruan


 
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
Cannot select multiple controls Blue Max New Users to Excel 3 March 14th 10 07:28 AM
Delete Blank Rows Code - Multiple Worksheets - Multiple Documents BenS Excel Discussion (Misc queries) 3 June 29th 07 12:20 AM
Multiple Option Controls w/in Worksheet uberbetty Excel Worksheet Functions 1 July 30th 06 11:33 PM
ActiveX Controls vs Form Controls Alex Excel Discussion (Misc queries) 1 January 11th 06 08:46 AM
Same event procedure for multiple controls Mikhail Excel Programming 1 October 13th 03 03:23 PM


All times are GMT +1. The time now is 07:11 PM.

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"