View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Cell Reference on a different sheet

Try the below. Please change the workbook name and the sheet name accordingly

Dim strValue As String

strValue = Workbooks("Book5").Sheets("Sheet1").Range("A1")
strValue = ActiveSheet.Range("A1")
strValue = ActiveSheet.Cells(1, 1)



If this post helps click Yes
---------------
Jacob Skaria


"Bishop" wrote:

Now I'm getting Error: Type Mismatch. Do I have to change Dim...String?

"Jacob Skaria" wrote:

MycellVal = Sheets(Sheet1).Range("A1")
OR
MycellVal = Sheets(Sheet1).Cells(1,1)
OR
MycellVal = Sheets(<Sheetindex).Range("A1")


If this post helps click Yes
---------------
Jacob Skaria


"Bishop" wrote:

I'm trying to use this code

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim MyCell As String
'Change callout here as desired
MyCell = "Z1"

If Range(MyCell).ValueThen
Exit Sub
Else
MsgBox "Please use a value of ""P"" or ""F"" in appropriate cells!", ,
"Invalid Entry"

End If
End Sub

Which works fine if Z1 is on the current sheet (Sheet 1). But I want to
reference a cell on a different sheet (Sheet 3) in the same workbook. How do
I do this?

MyCell = "Sheet3!Z1"
MyCell = "'Sheet3!'Z1"
doesn't work...