Array with dates

  • I need some help in this guys, I have an existing column fill with date and I want to add another column beside it with values depending on the date. For example from from 01/01/2015 to 02/15/2015 as January and so on. In this particular format, I tried using codes from my other projects but it does not work. Here are the code:




  • Re: Array with dates


    Code
    a = [{"01/18/2015", Jan; "01/19/2015", Jan]


    you have used "a" as array where as you are using "v" for output value?


    Code
    for each cell in WS.Range(WS.Range("A1"), WS.Cells(LR, 3)) 
            cell.EntireRow.Cells(Found.Column + 2).Value = IIf(IsError(v), "", v) 
     next cell
  • Re: Array with dates


    Hi. Sorry I have missed out a line while posting. I have edited it. And what i am trying to achieve is for example in column A, there will be a set of dates from 01/01/2015 until 12/31/2015. What i am trying to do is to create a column and base on the dates on column A to give the new column value. And yes the pattern would be from 01/15/2015 - 02/15/2015 as january.
    02/16/2015 - 03/15/2015 as february. and it goes on.


    Thanks.

  • Re: Array with dates


    just use this and change the range as per your's :smile:


    Code
    For Each cell In Range("A2:A51")
    If Day(cell) < 15 Then
    cell.Offset(0, 1).Value = Format(DateAdd("m", -1, cell), "MMM")
    Else
    cell.Offset(0, 1).Value = Format(cell, "MMM")
    End If
    Next cell

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!