VBA code to add current date in next cell

2019-08-02 05:46发布

enter image description hereI have below data (attached), which I have to add manually everyday. Now, I am trying to automate it.

  1. I would want to add current date in the next cell available (Ex : Cell E1)
  2. Second cell (E2), should get the return value of rows visible after autofilter from another Sheet named "Stock".

enter image description here

Please help me with these two codes.

1条回答
The star\"
2楼-- · 2019-08-02 06:27
Sub main()
    With Range("A1").CurrentRegion
        .Offset(, .Columns.Count).Resize(2, 1) = Application.Transpose(Array(Date, Application.WorksheetFunction.Subtotal(103, Worksheets("Stock").UsedRange.Columns(1).SpecialCells(XlCellType.xlCellTypeVisible))))
    End With
End Sub
查看更多
登录 后发表回答