View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
david mcritchie david mcritchie is offline
external usenet poster
 
Posts: 691
Default How to reference in sheet module value on another sheet?

But I think you would have to use Data Validation to
prevent a change from taking place.
http://www.contextures.com/xlDataVal06.html
http://www.mvps.org/dmcritchie/excel/validation.htm

=MyValidation("Joe")

since you cannot refer directly to another worksheet
in a validation formula.

Create a Function to make use of the above similar to Tom's
correction within the macro you had. You might use the userid
http://www.mvps.org/dmcritchie/excel/userid.htm

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Tom Ogilvy" wrote in message ...
If Worksheets("Sheet2").Range("ceUserName).Value < "Joe" then

--
Regards,
Tom Ogilvy


"Gregg" wrote in message
oups.com...
Excel 2002 sp1

How can I reference, in a sheet module, a value on another sheet?

Ex. In a sheet module (Sheet1) I have the following code (simplified
for the example):

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("ceUserName").Value < "Joe" then
MsgBox "You are not authorized to change this."
Exit Sub
End If
End Sub

Range("ceUserName").Value - is a value from a range on another sheet
(Sheet1). It is a simple named cell.

My code, here in the sheet module for Sheet 1, will not reference to
that value. I get a 1004 error.

How can I reference, in a sheet module, a value on another sheet?

Thanks for your help,
Gregg