Hide columns based on either todays date or a set date

  • Hello,

    Very new to VBA and new to this website as well. I was wondering if I could get some help with a workbook I am creating. It is a financial statement package that has multiple reports written inside. However, I would like to be able to hide month columns based on a set date. For example, when a user wants to run the reports, I would like the month columns that have not happened yet automatically hidden from the user since no information will be in those columns. Any help would be awesome. Let me know if more information is needed. However, I cant send the file since there is financial information disclosed.

  • Of course it's possible, I suggest attaching a sample file with the layout you have and want (dummy data please), it will be easier to explain.
    Guessing is not such a good option to start on this

    "IT" Always crosses your path :)

  • Code
    sub maybe()
    Dim y 
    'Change 6 with your month
    y =Filter([transpose(iferror(if(text(a1:a1000,"m")=6,"A" & row(a1:a1000)),False))],False,0)
    If ubound y>= 0 then range(y).EntireRow.Hidden = True
    end Sub
  • Or you can use filter by date

    Sub aaa()
              With sheet1.A1.CurrentRegion
                .autofilter 1,">" & date ,XlAnd, 1, "<" & date + 10
              .Specialcells(12).EntireRow.hidden = True
            end with
           end sub

Participate now!

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