PLOTTING BASED ON MONTH/YEAR [DATE] MACROS

  • Thread starter undergrowthseer
  • Start date
U

undergrowthseer

ei guys,

i have some problems regarding plotting[marking] dates.

i have this table where it shows 12 months based on the current date it
is run, so let's say it's october 7, 2005 today, my macros would plot
12 succeeding months starting october.

eg.

oct05 nov05 dec05 jan06 feb06 .... etc

now what i need to do is to mark the months based on to other dates the
user would fill up.

eg.

1st date: 11/15/2005
2nd date: 12/01/2006


now i have to put a mark the area where the input dates are in the
table i created:

eg.

oct05 nov05 dec05 jan06 feb06 .... etc
x x x x ....


but the my problem is i can't seem to get the year properly, i always
get an output like this one:


eg.


oct05 nov05 dec05 jan06 feb06 .... etc
x x

and that's it, i dont know what to do for it to mark until next year.

here's a part of my code:

Dim totalyr As Integer
Dim totalmo As Integer
Dim x As Integer



'Sheets("ATR").Select
Range("O1").Select
ActiveCell.Offset(1, 0).Select

indate = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
offdate = ActiveCell.Value

modatein = Month(indate)
yrdatein = Year(indate)

modateoff = Month(offdate)
yrdateoff = Year(offdate)

totalyr = yrdateoff - yrdatein
'get how many months
If totalyr >= 1 Then
totalmo = DateDiff("m", indate, offdate)
End If
If totalyr = 0 Then
totalmo = modateoff - modatein + 1
End If

'getting start plot month
Range("Q1").Select
celldate = ActiveCell.Value
mocelldate = Month(celldate)
yrcelldate = Year(celldate)
'getting difference of start plot date from roll in date
datetotal = DateDiff("m", celldate, indate)
If datetotal <= 12 Then
ActiveCell.Offset(0, datetotal).Select
ActiveCell.Offset(1, 0).Select
steps = 12 - datetotal
Else
If datetotal > 12 And datetotal < 0 Then
Range("Q3").Select
End If
End If
If datetotal > 12 Then
ActiveCell.Offset(0, 0).Select
ActiveCell.Offset(1, 0).Select
steps = 12 - datetotal
End If

'checks if roll in date is before start plot date
If celldate > indate Then
excessdate = mocelldate - modatein
End If

'goes to the cell where plot starts
If datetotal <= excessdate Then
For x = 1 To excessdate
ActiveCell.Offset(0, 1).Select
Next
End If

'get remaining months for plotting
remainingdate = datetotal - excessdate
If plottedmonths <= remainingdate Then
For x = 0 To remainingdate
ActiveCell.Value = "1"
ActiveCell.Offset(0, 1).Select
Next
End If


it's actually almost my whole, i hope someone can help.

thanks man
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top