Adding date to bottom of worksheet

  • Thread starter Thread starter CELCAT
  • Start date Start date
C

CELCAT

Hello all,

I'm trying to add the current date and some text to the bottom of a
worksheet though the worksheet will have changing numbers of rows. Anyone
know how to do this?

Regards

Chris
 
Hello all,

I'm trying to add the current date and some text to the bottom of a
worksheet though the worksheet will have changing numbers of rows. Anyone
know how to do this?

Regards

Chris

Chris,

Can you define "the bottom of a worksheet"? (UsedRange will return
the used range of a worksheet (which you can leverage to get the last
row), going to the last row of a specified column and then doing .End
(xlUp) will get you to the "last" non-empty cell in a column, and
there are other ways depending on what you are trying to accomplish).
Without knowing your definition of "bottom" it's hard to tell what
will be most useful to you.

Best,

Matthew Herbert
 
Hi Matthew,

Thanks for the quick response. Sorry for not being clearer.

I'm importing a stored proceedure from SQL and it's populating the worksheet
but I'd like to add the date on one line and some text under it leaving a 1
row space after the last row of data. The trouble I have is that the amount
of data will very so the last row will keep changing. Does that make sense?

Regards

Chris
 
Give this macro a try...

Sub AddDateAtBottom()
Dim LastUsedRow As Long
With ActiveSheet
LastUsedRow = .Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious).Row
.Cells(LastUsedRow + 2, "A").Value = Date
.Cells(LastUsedRow + 3, "A").Value = "Some additional text"
End With
End Sub
 
Back
Top