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: 48
Default Same code in several sheets..

Hi All,

I have following code repeated in Four sheets ina
workbbok containg ten sheets. and some other code in
another four sheets

Is there a way that I can avoid this repetation?

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo doTHIS
Application.EnableEvents = False
If Target.Address = "$D$4" Then
FindMatch
End If
doTHIS:
Application.EnableEvents = True

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As
Range)

If Target.Address = "$C$10" Then

Set rng = Range("C4:C8")
On Error GoTo Dotry
Application.EnableEvents = 0
If Application.CountA(rng) < 5 Then
MsgBox "Enter All Records!", vbOKOnly, _
"Invalid Record found"
ActiveSheet.Unprotect Password:="adfm"
rng.SpecialCells(xlBlanks)(1).Select
ActiveSheet.Protect Password:="adfm"
ActiveSheet.EnableSelection = xlUnlockedCells
Exit Sub
Else
DoIt
End If
End If
Dotry:
Application.EnableEvents = True
End Sub

TIA
Soniya
 
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
Code in certain sheets MAX Excel Worksheet Functions 1 February 6th 10 09:27 PM
sum across range of sheets for a cost code monkeydoom Excel Worksheet Functions 1 August 25th 09 03:29 PM
Code to hide sheets Tia[_3_] Excel Worksheet Functions 0 July 8th 08 11:07 AM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Worksheet Functions 6 March 29th 06 12:43 PM
Formating Sheets made in Code Jenn Excel Discussion (Misc queries) 1 August 22nd 05 05:19 PM


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