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

Hello,

Does anyone know how to compare an input date with the current date? The
macro I'm using adds ordered item quantities to the current inventory balance
without regard to the current date. For example, if parts ordered are due on
06/30/06 and today's date is 06/29/06, the ordered part quantity immediately
adds it to the current balance.

Here's the full sub:

=========================

Sub macro2()
Dim orderpart(500, 1)
Dim orderpartqty(500, 2)


Sheets("On Order Parts").Select
countorder = 0
While (IsEmpty(Cells(2 + countorder, 1))) = False
countorder = countorder + 1
Wend

For i = 1 To countorder Step 1
orderpart(i, 1) = Cells(1 + i, 1)
orderpartqty(i, 2) = Cells(1 + i, 2)
Next i

'adds the number of parts in consolidated list
Sheets("Manage").Select
newlist = 0
While (IsEmpty(Cells(6 + newlist, 1))) = False
newlist = newlist + 1
Wend

'removes previous highlighted rows
Range(Cells(6, 1), Cells(newlist + 6, 7)).Select
With Selection.Interior
.ColorIndex = 2
.PatternColorIndex = xlAutomatic
End With
Range(Cells(6, 5), Cells(newlist + 6, 5)).Select
Selection.ClearContents

'adds qty for part number from "On Order Parts"
i = 0
j = 0
For i = 1 To countorder Step 1
For j = 1 To newlist Step 1
If Cells(5 + j, 1) = orderpart(i, 1) Then
Cells(5 + j, 6) = orderpartqty(i, 2)
End If
Next j
Next i


'Updates Qty on order to Balance
For t = 1 To newlist Step 1

Cells(5 + t, 4) = Cells(5 + t, 2) - Cells(5 + t, 3) + Cells(5 + t, 6)
If Cells(5 + t, 4) <= 20 Then
Cells(5 + t, 5) = "Order Parts!"
Range(Cells(5 + t, 1), Cells(5 + t, 7)).Select
Selection.Font.Bold = True
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
If Cells(5 + t, 4) 20 And Cells(5 + t, 4) <= 50 Then
Cells(5 + t, 5) = "Balance Low"
Range(Cells(5 + t, 1), Cells(5 + t, 7)).Select
Selection.Font.Bold = True
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
Next t
Cells(6, 1).Select

End Sub

===========================

Thanks a bunch!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Date Comparison

Current date you can get via Date function, then
compare it with any date using ,< and so on.
If your input date variable type is not "date", ex. string, use cdate()
function beforehand.

"dzuy" wrote:

Hello,

Does anyone know how to compare an input date with the current date? The
macro I'm using adds ordered item quantities to the current inventory balance
without regard to the current date. For example, if parts ordered are due on
06/30/06 and today's date is 06/29/06, the ordered part quantity immediately
adds it to the current balance.

Here's the full sub:

=========================

Sub macro2()
Dim orderpart(500, 1)
Dim orderpartqty(500, 2)


Sheets("On Order Parts").Select
countorder = 0
While (IsEmpty(Cells(2 + countorder, 1))) = False
countorder = countorder + 1
Wend

For i = 1 To countorder Step 1
orderpart(i, 1) = Cells(1 + i, 1)
orderpartqty(i, 2) = Cells(1 + i, 2)
Next i

'adds the number of parts in consolidated list
Sheets("Manage").Select
newlist = 0
While (IsEmpty(Cells(6 + newlist, 1))) = False
newlist = newlist + 1
Wend

'removes previous highlighted rows
Range(Cells(6, 1), Cells(newlist + 6, 7)).Select
With Selection.Interior
.ColorIndex = 2
.PatternColorIndex = xlAutomatic
End With
Range(Cells(6, 5), Cells(newlist + 6, 5)).Select
Selection.ClearContents

'adds qty for part number from "On Order Parts"
i = 0
j = 0
For i = 1 To countorder Step 1
For j = 1 To newlist Step 1
If Cells(5 + j, 1) = orderpart(i, 1) Then
Cells(5 + j, 6) = orderpartqty(i, 2)
End If
Next j
Next i


'Updates Qty on order to Balance
For t = 1 To newlist Step 1

Cells(5 + t, 4) = Cells(5 + t, 2) - Cells(5 + t, 3) + Cells(5 + t, 6)
If Cells(5 + t, 4) <= 20 Then
Cells(5 + t, 5) = "Order Parts!"
Range(Cells(5 + t, 1), Cells(5 + t, 7)).Select
Selection.Font.Bold = True
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
If Cells(5 + t, 4) 20 And Cells(5 + t, 4) <= 50 Then
Cells(5 + t, 5) = "Balance Low"
Range(Cells(5 + t, 1), Cells(5 + t, 7)).Select
Selection.Font.Bold = True
With Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
Next t
Cells(6, 1).Select

End Sub

===========================

Thanks a bunch!

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
Date Comparison Vic Excel Discussion (Misc queries) 1 October 22nd 09 03:18 PM
Date Comparison Christopher Naveen[_2_] Excel Worksheet Functions 1 August 13th 09 06:01 AM
date comparison oldLearner57 Excel Discussion (Misc queries) 2 March 29th 09 04:45 PM
VBA: Date Comparison dzuy Excel Programming 2 June 29th 06 04:52 PM
Date comparison Jonibenj Excel Discussion (Misc queries) 6 October 23rd 05 08:34 PM


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

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

About Us

"It's about Microsoft Excel"