excel VBA problem

Z

Zygoid

I am using this in workbook(1) to search text in cell D3 in a range of
workbook(2). if the text in D3 is not found in the range of wb2 then a
form opens up to - add information into wb2, save the changes in wb2,
and then close wb2. this all works fine.

Private Sub Worksheet_Change(ByVal Target As Range)
With Target(1)
If .Address = "$D$3" Then
If .Value <> "" Then
Application.ScreenUpdating = False
Set sourcewb = Workbooks.Open("path/to/wb2")
ActiveWorkbook.Sheets("1").Activate
If Sheets("1").Range("A1:A200").Find( _
what:=.Value) Is Nothing Then
sourcewb.Close True
FORM.Show
End If
End If
End If
End With

the problem is that if D3 is found in wb2. wb2 doesn't close.
i am guessing i need an ElseIf but not sure how to code it.

any idea's?
 
J

JE McGimpsey

See one possible answer in your previous thread:

"what does (ByVal Target As Excel.Range)" mean"
 

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

Similar Threads


Top