• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

adding column

vaishnavee

New Member
i want to add the column after ending of every month, how to write the vba code for this??? i have dates in the column , not all dates of the months are present.
 

Attachments

p45cal

Well-Known Member
Before running the macro below, select the dates, a single row with dates in every cell. This selection is what the macro will look at.
Make sure when you run it that the active sheet is the one you want to add columns to.
Code:
Sub blah()
Set Rng = Selection
For c = Rng.Columns.Count To 2 Step -1
  Rng.Cells(c).Select
  If Application.EoMonth(Rng.Cells(c).Value, 0) <> Application.EoMonth(Rng.Cells(c - 1).Value, 0) Then
    Rng.Cells(c).EntireColumn.Insert
  End If
Next c
End Sub
 
Top