ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find date in another workbook (https://www.excelbanter.com/excel-programming/298007-find-date-another-workbook.html)

scain2004[_5_]

Find date in another workbook
 
I need to find a date in Production Calendar.xls from Production Jo
List.xls. So far this is what I've got:

Workbooks("Productio
Calendar.xls").Worksheets("Phoenix").Range("A:G"). Cells
.Find(What:="9/24/2004", LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext
MatchCase:=False).Activate

message = CStr(ActiveCell.Location)



On the find statement I get an "Invalid or unqualified reference
error.

Actually, in the calendar itself the date is in format "24-Sep", no
sure if that matters or not since it's a date.

Any suggestions?

Thanks

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


Melanie Breden

Find date in another workbook
 
I need to find a date in Production Calendar.xls from Production Job
List.xls. So far this is what I've got:

Workbooks("Production
Calendar.xls").Worksheets("Phoenix").Range("A:G"). Cells
Find(What:="9/24/2004", LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activate

message = CStr(ActiveCell.Location)


On the find statement I get an "Invalid or unqualified reference"
error.

Actually, in the calendar itself the date is in format "24-Sep", not
sure if that matters or not since it's a date.


try this:

Sub FindDate()
Dim rngDate As Range

On Error Resume Next
Set rngDate = Workbooks("Production Calendar.xls").Worksheets("Phoenix") _
.Range("A:G").Cells.Find(#9/24/2004#)

If Not rngDate Is Nothing Then
MsgBox rngDate.Address
Else
MsgBox "Date not found"
End If
End Sub

--
Regards
Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)


scain2004[_6_]

Find date in another workbook
 
Ok, I tried it exactly like that and it gave me a "Object Variable o
With block variable not set" error

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


Melanie Breden

Find date in another workbook
 
Ok, I tried it exactly like that and it gave me a "Object Variable or
With block variable not set" error.


This error message cannot take place with the code, because
"On Error Resume Next" is set and the IF instruction is closed.

Did you examine whether is correctly written the file and sheet name?
Are the date values real, or generate by formulas ?

--
Regards
Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)


scain2004[_7_]

Find date in another workbook
 
it didn't stop the code, but when I stepped through it, it showed the
error.

Anyways, I did figure it out and now it's working how I need it to with
some proper formatting. :)


Thank you for your help!


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



All times are GMT +1. The time now is 10:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com