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

I am currently working with an inventory Excel spreadsheet. There are two
worksheets: "Manage" and "On Order Parts".

Whenever I input an order into "On Order Parts" with order due date and
quantity information. The "Manage" worksheet updates the parts balance with
the on-order-quantity and does not consider the due date (it adds the
on-order-quantity regardless of the order due date). I've isolated the
problem to the segment of the macro that would need to be modified in order
to consider the due date:

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

'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

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

I think it should have an IF statement before the line:

Cells(5 + t, 4) = Cells(5 + t, 2) - Cells(5 + t, 3) + Cells(5 + t, 6)

But I don't know how to reference cells from another worksheet in VBA and
compare it to the current date. Maybe something like this (with the correct
syntax, of course):

If **Due Date** - **Today's Date** = 0 Then

I know it just needs this one line! Can anyone help me out? Thanks!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default VBA Coding: Date Consideration

To reference cells from the other sheet, use worksheets(index).cells(row,col)
or worksheets(index).cells(row,col)
or activeworkbook.worksheets(index).cells(row,col) or
activeworkbook.sheets(index).cells(row,col) if you workbook is active.
Instead of index you can use name of sheet. Ex. Sheets("Sheet1").
To refer to ActiveSheet use ActiveSheet.cels(row,col).
To get current date, use Date function.

regards, Irina



"dzuy" wrote:

I am currently working with an inventory Excel spreadsheet. There are two
worksheets: "Manage" and "On Order Parts".

Whenever I input an order into "On Order Parts" with order due date and
quantity information. The "Manage" worksheet updates the parts balance with
the on-order-quantity and does not consider the due date (it adds the
on-order-quantity regardless of the order due date). I've isolated the
problem to the segment of the macro that would need to be modified in order
to consider the due date:

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

'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

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

I think it should have an IF statement before the line:

Cells(5 + t, 4) = Cells(5 + t, 2) - Cells(5 + t, 3) + Cells(5 + t, 6)

But I don't know how to reference cells from another worksheet in VBA and
compare it to the current date. Maybe something like this (with the correct
syntax, of course):

If **Due Date** - **Today's Date** = 0 Then

I know it just needs this one line! Can anyone help me out? Thanks!


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
Formula that takes a range of values into consideration Andmor Excel Discussion (Misc queries) 9 January 29th 10 11:46 PM
Date and User restriction coding PSM[_19_] Excel Worksheet Functions 1 November 19th 09 07:03 PM
Coding Custom Date Functions in Excel [email protected] Excel Worksheet Functions 1 May 8th 09 10:01 AM
Calculating Months while taking into consideration days Excel Trouble[_2_] Excel Worksheet Functions 3 February 8th 08 05:57 PM
Coding to show first _weekday_ prior to a date, when date calculation happens to fall on weekend? StargateFan[_3_] Excel Programming 5 December 9th 04 09:06 AM


All times are GMT +1. The time now is 07:26 PM.

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"