Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Noemi
 
Posts: n/a
Default Using Target.Address in Excel 98

Hi
I have a code which as Target.Address which works in Excel 2000 but will not
work in excel 98.

Does anyone know what code to use for when a workbook change is to take
affect.

The current code which works in Excel 2000 is below:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$G$26" Then
If Range("G26") = "Other" Then
ActiveSheet.Unprotect
Sheets("Recording Sheet").Range("E28") = "Please speficy:"
Sheets("Recording Sheet").Range("G28:I28").Interior.ColorIndex = 2
Sheets("Recording Sheet").Range("G28:I28") = ""
Sheets("Recording Sheet").Range("G28:I28").Locked = False
ActiveSheet.Protect
Sheets("Recording Sheet").Range("G28:I28").Select
ElseIf Range("G26").Value = "" Then
ActiveSheet.Unprotect
Sheets("Recording Sheet").Range("E28") = ""
Sheets("Recording Sheet").Range("G28:I28") = ""
Sheets("Recording Sheet").Range("G28:I28").Interior.ColorIndex = 1
Sheets("Recording Sheet").Range("G28:I28").Locked = True
ActiveSheet.Protect
Else
ActiveSheet.Unprotect
Sheets("Recording Sheet").Range("E28") = ""
Sheets("Recording Sheet").Range("G28:I28") = ""
Sheets("Recording Sheet").Range("G28:I28").Interior.ColorIndex = 1
Sheets("Recording Sheet").Range("G28:I28").Locked = True
ActiveSheet.Protect
End If
End If
End Sub

Any help would be appreciated.

Thanks
Noemi
  #2   Report Post  
Don Guillett
 
Posts: n/a
Default Using Target.Address in Excel 98

I know of no excel 98. Please clarify. I just tested
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$A$2" Then MsgBox "Hi"
End Sub
in xl97sr2 on xp home and it worked just fine.
is recordingsheet your active sheet?
=====something like this would be cleaner
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address < "$G$26" Then Exit Sub
With Target.Worksheet
.Unprotect
If UCase(Target) = "OTHER" Then
.Range("E28") = "Please speficy:"
.Range("G28:I28").Interior.ColorIndex = 2
.Range("G28:I28") = ""
.Range("G28:I28").Locked = False
Else
.Range("E28,G28:I28") = ""
.Range("G28:I28").Interior.ColorIndex = 1
.Range("G28:I28").Locked = True
End If
.Protect
End With
End Sub



--
Don Guillett
SalesAid Software

"Noemi" wrote in message
...
Hi
I have a code which as Target.Address which works in Excel 2000 but will

not
work in excel 98.

Does anyone know what code to use for when a workbook change is to take
affect.

The current code which works in Excel 2000 is below:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$G$26" Then
If Range("G26") = "Other" Then
ActiveSheet.Unprotect
Sheets("Recording Sheet").Range("E28") = "Please speficy:"
Sheets("Recording Sheet").Range("G28:I28").Interior.ColorIndex = 2
Sheets("Recording Sheet").Range("G28:I28") = ""
Sheets("Recording Sheet").Range("G28:I28").Locked = False
ActiveSheet.Protect
Sheets("Recording Sheet").Range("G28:I28").Select
ElseIf Range("G26").Value = "" Then
ActiveSheet.Unprotect
Sheets("Recording Sheet").Range("E28") = ""
Sheets("Recording Sheet").Range("G28:I28") = ""
Sheets("Recording Sheet").Range("G28:I28").Interior.ColorIndex = 1
Sheets("Recording Sheet").Range("G28:I28").Locked = True
ActiveSheet.Protect
Else
ActiveSheet.Unprotect
Sheets("Recording Sheet").Range("E28") = ""
Sheets("Recording Sheet").Range("G28:I28") = ""
Sheets("Recording Sheet").Range("G28:I28").Interior.ColorIndex = 1
Sheets("Recording Sheet").Range("G28:I28").Locked = True
ActiveSheet.Protect
End If
End If
End Sub

Any help would be appreciated.

Thanks
Noemi



  #3   Report Post  
Jim Rech
 
Posts: n/a
Default Using Target.Address in Excel 98

You would have a better chance of getting help if you tell us exactly where
the code breaks down.

One no-no you've commited though is not turning off events in the sheet
change event handler when your code is itself making changes to the sheet.
This causes an endless loop in theory. So add an Application.EnableEvents =
False before making a sheet change, and set the same to True after your last
sheet change.

--
Jim
"Noemi" wrote in message
...
| Hi
| I have a code which as Target.Address which works in Excel 2000 but will
not
| work in excel 98.
|
| Does anyone know what code to use for when a workbook change is to take
| affect.
|
| The current code which works in Excel 2000 is below:
|
| Private Sub Worksheet_Change(ByVal Target As Range)
| If Target.Address = "$G$26" Then
| If Range("G26") = "Other" Then
| ActiveSheet.Unprotect
| Sheets("Recording Sheet").Range("E28") = "Please speficy:"
| Sheets("Recording Sheet").Range("G28:I28").Interior.ColorIndex = 2
| Sheets("Recording Sheet").Range("G28:I28") = ""
| Sheets("Recording Sheet").Range("G28:I28").Locked = False
| ActiveSheet.Protect
| Sheets("Recording Sheet").Range("G28:I28").Select
| ElseIf Range("G26").Value = "" Then
| ActiveSheet.Unprotect
| Sheets("Recording Sheet").Range("E28") = ""
| Sheets("Recording Sheet").Range("G28:I28") = ""
| Sheets("Recording Sheet").Range("G28:I28").Interior.ColorIndex = 1
| Sheets("Recording Sheet").Range("G28:I28").Locked = True
| ActiveSheet.Protect
| Else
| ActiveSheet.Unprotect
| Sheets("Recording Sheet").Range("E28") = ""
| Sheets("Recording Sheet").Range("G28:I28") = ""
| Sheets("Recording Sheet").Range("G28:I28").Interior.ColorIndex = 1
| Sheets("Recording Sheet").Range("G28:I28").Locked = True
| ActiveSheet.Protect
| End If
| End If
| End Sub
|
| Any help would be appreciated.
|
| Thanks
| Noemi


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
"Group" function very slow with Excel 2003 :( ... While very quick with Excel2000 :O) Alain79 Excel Discussion (Misc queries) 4 June 14th 05 07:34 AM
Stop Excel Rounding Dates leinad512 Excel Discussion (Misc queries) 1 April 20th 05 04:19 PM
Hints And Tips For New Posters In The Excel Newsgroups Gary Brown Excel Worksheet Functions 0 April 15th 05 05:47 PM
Excel error - Startup (and Acrobat PDFMaker) gxdata Setting up and Configuration of Excel 0 February 4th 05 03:44 AM
Excel 2002 and 2000 co-install. Control Which Starts ? cnuk Excel Discussion (Misc queries) 2 January 17th 05 08:07 PM


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