ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Compare dates in two worksheets (https://www.excelbanter.com/excel-programming/432749-compare-dates-two-worksheets.html)

laavista

Compare dates in two worksheets
 
I'm using Excel 2003, and I really need help.

I am comparing two dates; 1 date is in worksheet1 and the other date is in
worksheet2. Both date columns are formatted as mm/dd/yy

I pick up the date in worksheet1 and store it in varaible "OrigOrderDate"
(string variable)

I use the following to locate the correct ID in worksheet2, the row in which
the date I want to compare is located. The Row is stored in variable
FoundRow.
Set C = .Find(profileid, LookIn:=xlValues, LookAt:=xlWhole)
The date I want to compare is in column 3

It finds the ID and the FoundRow is correct

I use the following to store the date in worksheet2 in the string variable
OrderDateInOrders.
OrderDateInOrders = Cells(FoundRow, 3)

When I step through the procedure, after I PASS the above statement and I
check what's stored in the variables, the OrderDateInOrders did not pick up
the date in cells(FoundRow,3).

After the procedure is PASSED the values a
OrderDateInOrders = "8/6/2009"
Cells(FoundRow,3) = 8/12/2009


I tried changing the variables to a date format, then this failed:
Set C = .Find(profileid, LookIn:=xlValues, LookAt:=xlWhole)

Your help would be GREATLY appreciated!

Jacob Skaria

Compare dates in two worksheets
 
Are you sure you are referring to the correct sheet

OrderDateInOrders = Worksheets("Sheet2").Cells(FoundRow, 3)


If this post helps click Yes
---------------
Jacob Skaria


"laavista" wrote:

I'm using Excel 2003, and I really need help.

I am comparing two dates; 1 date is in worksheet1 and the other date is in
worksheet2. Both date columns are formatted as mm/dd/yy

I pick up the date in worksheet1 and store it in varaible "OrigOrderDate"
(string variable)

I use the following to locate the correct ID in worksheet2, the row in which
the date I want to compare is located. The Row is stored in variable
FoundRow.
Set C = .Find(profileid, LookIn:=xlValues, LookAt:=xlWhole)
The date I want to compare is in column 3

It finds the ID and the FoundRow is correct

I use the following to store the date in worksheet2 in the string variable
OrderDateInOrders.
OrderDateInOrders = Cells(FoundRow, 3)

When I step through the procedure, after I PASS the above statement and I
check what's stored in the variables, the OrderDateInOrders did not pick up
the date in cells(FoundRow,3).

After the procedure is PASSED the values a
OrderDateInOrders = "8/6/2009"
Cells(FoundRow,3) = 8/12/2009


I tried changing the variables to a date format, then this failed:
Set C = .Find(profileid, LookIn:=xlValues, LookAt:=xlWhole)

Your help would be GREATLY appreciated!


Mishell

Compare dates in two worksheets
 
Try replacing in your statements
LookIn:=xlValues
by
LookIn:=xlFormulas

Mishell

"laavista" wrote in message
...
I'm using Excel 2003, and I really need help.

I am comparing two dates; 1 date is in worksheet1 and the other date is
in
worksheet2. Both date columns are formatted as mm/dd/yy

I pick up the date in worksheet1 and store it in varaible "OrigOrderDate"
(string variable)

I use the following to locate the correct ID in worksheet2, the row in
which
the date I want to compare is located. The Row is stored in variable
FoundRow.
Set C = .Find(profileid, LookIn:=xlValues, LookAt:=xlWhole)
The date I want to compare is in column 3

It finds the ID and the FoundRow is correct

I use the following to store the date in worksheet2 in the string variable
OrderDateInOrders.
OrderDateInOrders = Cells(FoundRow, 3)

When I step through the procedure, after I PASS the above statement and I
check what's stored in the variables, the OrderDateInOrders did not pick
up
the date in cells(FoundRow,3).

After the procedure is PASSED the values a
OrderDateInOrders = "8/6/2009"
Cells(FoundRow,3) = 8/12/2009


I tried changing the variables to a date format, then this failed:
Set C = .Find(profileid, LookIn:=xlValues, LookAt:=xlWhole)

Your help would be GREATLY appreciated!




laavista

Compare dates in two worksheets
 
THANK YOU so much. I can't believe I did not explictly refer to the
worksheet. This work.

THANKS!!!!!



"Jacob Skaria" wrote:

Are you sure you are referring to the correct sheet

OrderDateInOrders = Worksheets("Sheet2").Cells(FoundRow, 3)


If this post helps click Yes
---------------
Jacob Skaria


"laavista" wrote:

I'm using Excel 2003, and I really need help.

I am comparing two dates; 1 date is in worksheet1 and the other date is in
worksheet2. Both date columns are formatted as mm/dd/yy

I pick up the date in worksheet1 and store it in varaible "OrigOrderDate"
(string variable)

I use the following to locate the correct ID in worksheet2, the row in which
the date I want to compare is located. The Row is stored in variable
FoundRow.
Set C = .Find(profileid, LookIn:=xlValues, LookAt:=xlWhole)
The date I want to compare is in column 3

It finds the ID and the FoundRow is correct

I use the following to store the date in worksheet2 in the string variable
OrderDateInOrders.
OrderDateInOrders = Cells(FoundRow, 3)

When I step through the procedure, after I PASS the above statement and I
check what's stored in the variables, the OrderDateInOrders did not pick up
the date in cells(FoundRow,3).

After the procedure is PASSED the values a
OrderDateInOrders = "8/6/2009"
Cells(FoundRow,3) = 8/12/2009


I tried changing the variables to a date format, then this failed:
Set C = .Find(profileid, LookIn:=xlValues, LookAt:=xlWhole)

Your help would be GREATLY appreciated!



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

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