missing worksheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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).
 
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"))
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top