ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   perpetual dates (https://www.excelbanter.com/excel-discussion-misc-queries/52414-perpetual-dates.html)

willray

perpetual dates
 
Is there a way to have excel automatically add a new date to the end of a
column each day? My goal is to have an automatic date in column A and daily
closing prices for the S&P500(in column B) corresponding to those dates that
are updated via web query. Thanks so much!

Dave Peterson

perpetual dates
 
Maybe...

Option Explicit
Sub auto_open()
Dim LastCell As Range
With Worksheets("Sheet1")
Set LastCell = .Cells(.Rows.Count, "A").End(xlUp)
If LastCell.Value = Date Then
'already opened and populated
'do nothing
Else
With LastCell.Offset(1, 0)
.Value = Date
.NumberFormat = "mm/dd/yyyy"
End With
End If
End With
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

(I have no idea about the query, though.)

willray wrote:

Is there a way to have excel automatically add a new date to the end of a
column each day? My goal is to have an automatic date in column A and daily
closing prices for the S&P500(in column B) corresponding to those dates that
are updated via web query. Thanks so much!


--

Dave Peterson


All times are GMT +1. The time now is 12:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com