Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default excel VBA problem

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?


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default excel VBA problem

See one possible answer in your previous thread:

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


In article ,
Zygoid wrote:

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?


---
Message posted from http://www.ExcelForum.com/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Colon at the end of excel file name(ex: problem.xls:1, problem.xls financeguy New Users to Excel 2 January 15th 10 01:15 AM
Problem viewing Excel 2003 Pivot Chart fields in Excel 2007 ronny B Charts and Charting in Excel 1 October 24th 08 10:08 PM
Weird problem with Excel 2000...Worksheets disappearing in a shared Excel file BrianL_SF Excel Discussion (Misc queries) 2 October 10th 06 08:27 PM
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
EXCEL FORMAT PROBLEM WHEN SENDING EXCEL SHEET AS MESSAGE BODY IN . P.S.Sodha Excel Discussion (Misc queries) 0 April 2nd 05 01:53 PM


All times are GMT +1. The time now is 06:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"