missing worksheet

S

Smitty

In a worksheet (1) I want to search for the existence of another worksheet
(2). If found, I want to extract the value from that worksheet(2) into a cell
in the active worksheet (1). If not found I want to default to the value that
already exists in the cell in the active worksheet (1).
 
D

Don Guillett

try this. However, it not exist it gets the value from another cell. To use
the value from the SAME cell, you need a UDF macro

=IF(ISERROR(INDIRECT("'joe'!A1")),H1,INDIRECT("joe!A1"))
 
O

Otto Moehrbach

The following macro will do what you want. As written, the macro will check
if sheet "Two" exists. If it does, it will copy F1 of sheet "Two" and paste
it to A1 of the active sheet. If sheet "Two" does not exist it will do
nothing. HTH Otto
Sub GetData()
Dim wsh As Worksheet
On Error Resume Next
Set wsh = ActiveWorkbook.Worksheets("Two")
If Err <> 0 Then Exit Sub
Range("A1").Value = Sheets("Two").Range("F1").Value
End Sub
 
Top