Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Open Workbook, Go To Worksheet ABC, Find XYZ In Column B

Workbook named BaseWorkbook is open.

How do I write the following in Excel VBA:
Open C:\MyFolder\MyWorkBook.xls
Is there a worksheet named "ABC"
If No Then
Put text "No 'ABC'" in D4 of BaseWorkbook
End
If Yes
Go to "ABC"
Is the text "XYZ" in Column B
If No Then
Put text "No 'XYZ'" in D4 of BaseWorkbook
End
If Yes
Put value in column L of row containing "XYZ"
in D2 of BaseWorkbook
End

Thanks!

Steve


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 373
Default Open Workbook, Go To Worksheet ABC, Find XYZ In Column B

Steve, Copy this code and paste in a standard module of the base workbook.
Code assumes the base workbook's sheet where you want to put the results is
active.
If you don't want MyWorkbook closed, remove or rem out the lines ending in
..Close.
HTH, James

Sub ABCXYZ()
Dim A As Worksheet, B As Worksheet, c As Range
Set B = ActiveSheet
Workbooks.Open "MyWorkbook.xls"
On Error Resume Next
Set A = ActiveWorkbook.Worksheets("ABC")
If Err < 0 Then
B.[d4] = "No ABC"
Workbooks("MyWorkbook.xls").Close
Exit Sub
End If
On Error GoTo 0
Set c = A.Columns(2).Find("XYZ")
If c Is Nothing Then
B.[d4] = "No XYZ"
Else
B.[d2] = A.Cells(c.Row, "L")
End If
Workbooks("MyWorkbook.xls").Close
End Sub

" Steve" wrote in message
...
Workbook named BaseWorkbook is open.

How do I write the following in Excel VBA:
Open C:\MyFolder\MyWorkBook.xls
Is there a worksheet named "ABC"
If No Then
Put text "No 'ABC'" in D4 of BaseWorkbook
End
If Yes
Go to "ABC"
Is the text "XYZ" in Column B
If No Then
Put text "No 'XYZ'" in D4 of BaseWorkbook
End
If Yes
Put value in column L of row containing "XYZ"
in D2 of BaseWorkbook
End

Thanks!

Steve



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Open Workbook, Go To Worksheet ABC, Find XYZ In Column B

Hi James,

Thank you very much for the help! Have a nice weekend.

Steve


"Zone" wrote in message
...
Steve, Copy this code and paste in a standard module of the base workbook.
Code assumes the base workbook's sheet where you want to put the results
is active.
If you don't want MyWorkbook closed, remove or rem out the lines ending in
.Close.
HTH, James

Sub ABCXYZ()
Dim A As Worksheet, B As Worksheet, c As Range
Set B = ActiveSheet
Workbooks.Open "MyWorkbook.xls"
On Error Resume Next
Set A = ActiveWorkbook.Worksheets("ABC")
If Err < 0 Then
B.[d4] = "No ABC"
Workbooks("MyWorkbook.xls").Close
Exit Sub
End If
On Error GoTo 0
Set c = A.Columns(2).Find("XYZ")
If c Is Nothing Then
B.[d4] = "No XYZ"
Else
B.[d2] = A.Cells(c.Row, "L")
End If
Workbooks("MyWorkbook.xls").Close
End Sub

" Steve" wrote in message
...
Workbook named BaseWorkbook is open.

How do I write the following in Excel VBA:
Open C:\MyFolder\MyWorkBook.xls
Is there a worksheet named "ABC"
If No Then
Put text "No 'ABC'" in D4 of BaseWorkbook
End
If Yes
Go to "ABC"
Is the text "XYZ" in Column B
If No Then
Put text "No 'XYZ'" in D4 of BaseWorkbook
End
If Yes
Put value in column L of row containing "XYZ"
in D2 of BaseWorkbook
End

Thanks!

Steve





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 373
Default Open Workbook, Go To Worksheet ABC, Find XYZ In Column B

Glad to help! By the way, I just noticed Find "remembers" previous
settings, so this code will work best if you don't change the Find options
before running the code. I posted a new thread about that. Cheers, James
" Steve" wrote in message
...
Hi James,

Thank you very much for the help! Have a nice weekend.

Steve


"Zone" wrote in message
...
Steve, Copy this code and paste in a standard module of the base
workbook.
Code assumes the base workbook's sheet where you want to put the results
is active.
If you don't want MyWorkbook closed, remove or rem out the lines ending
in .Close.
HTH, James

Sub ABCXYZ()
Dim A As Worksheet, B As Worksheet, c As Range
Set B = ActiveSheet
Workbooks.Open "MyWorkbook.xls"
On Error Resume Next
Set A = ActiveWorkbook.Worksheets("ABC")
If Err < 0 Then
B.[d4] = "No ABC"
Workbooks("MyWorkbook.xls").Close
Exit Sub
End If
On Error GoTo 0
Set c = A.Columns(2).Find("XYZ")
If c Is Nothing Then
B.[d4] = "No XYZ"
Else
B.[d2] = A.Cells(c.Row, "L")
End If
Workbooks("MyWorkbook.xls").Close
End Sub

" Steve" wrote in message
...
Workbook named BaseWorkbook is open.

How do I write the following in Excel VBA:
Open C:\MyFolder\MyWorkBook.xls
Is there a worksheet named "ABC"
If No Then
Put text "No 'ABC'" in D4 of BaseWorkbook
End
If Yes
Go to "ABC"
Is the text "XYZ" in Column B
If No Then
Put text "No 'XYZ'" in D4 of BaseWorkbook
End
If Yes
Put value in column L of row containing "XYZ"
in D2 of BaseWorkbook
End

Thanks!

Steve







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
How to find file-path of open workbook? Larryq22 Excel Discussion (Misc queries) 7 January 24th 08 03:38 AM
Open a specific workbook...find value from other open workbook and then insert cells values in cell next to it. [email protected] Excel Programming 1 May 13th 07 01:46 PM
Open workbook macro- find correct month to open? buzzharley[_10_] Excel Programming 8 July 8th 06 04:30 AM
Copying A Worksheet From Each Open Workbook to an new Workbook carl Excel Worksheet Functions 1 January 3rd 06 05:37 PM
How to find if a workbook is open Amir Excel Programming 4 January 27th 04 10:26 PM


All times are GMT +1. The time now is 08:55 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"