Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11
Default Macro to Open Daily Report

Every day a report is posted online that I need to open; the report is
titled 080906_rpts_open.csv. Each morning I need to open the previous
days report or reports from over the weekend. I'm looking to write a
macro that would automatically open the report or reports based on how
many days I need to go back.
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro to Open Daily Report

One way:

Option Explicit
Sub testme()

Dim dCtr As Long
Dim StartDate As Long
Dim MaxDates As Long
Dim myPath As String
Dim myStr As String
Dim UseThisFile As String
Dim TestStr As String
Dim CSVWks As Worksheet

'start with yesterday?
StartDate = Date - 1

'don't look for more than this number days
MaxDates = 15

'change the path for the CSV files here
myPath = "C:\my documents\excel"
If Right(myPath, 1) < "\" Then
myPath = myPath & "\"
End If

UseThisFile = ""
For dCtr = StartDate To StartDate - MaxDates Step -1
myStr = myPath & Format(dCtr, "yymmdd") & "_rpts_open.csv"
TestStr = ""
On Error Resume Next
TestStr = Dir(myStr)
On Error GoTo 0

If TestStr = "" Then
'keep looking
Else
UseThisFile = myStr
Exit For
End If
Next dCtr

If UseThisFile = "" Then
MsgBox "No files found"
Else
Set CSVWks = Workbooks.Open(Filename:=myStr).Worksheets(1)
With CSVWks
'do lots of formatting???
End With
MsgBox "It's open!"
End If

End Sub


KurtB wrote:

Every day a report is posted online that I need to open; the report is
titled 080906_rpts_open.csv. Each morning I need to open the previous
days report or reports from over the weekend. I'm looking to write a
macro that would automatically open the report or reports based on how
many days I need to go back.
Thanks!


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11
Default Macro to Open Daily Report

Thanks... And if I want to pull this off a website What do I need to
change?


On Sep 9, 8:55*am, Dave Peterson wrote:
One way:

Option Explicit
Sub testme()

* * Dim dCtr As Long
* * Dim StartDate As Long
* * Dim MaxDates As Long
* * Dim myPath As String
* * Dim myStr As String
* * Dim UseThisFile As String
* * Dim TestStr As String
* * Dim CSVWks As Worksheet

* * 'start with yesterday?
* * StartDate = Date - 1

* * 'don't look for more than this number days
* * MaxDates = 15

* * 'change the path for the CSV files here
* * myPath = "C:\my documents\excel"
* * If Right(myPath, 1) < "\" Then
* * * * myPath = myPath & "\"
* * End If

* * UseThisFile = ""
* * For dCtr = StartDate To StartDate - MaxDates Step -1
* * * * myStr = myPath & Format(dCtr, "yymmdd") & "_rpts_open.csv"
* * * * TestStr = ""
* * * * On Error Resume Next
* * * * TestStr = Dir(myStr)
* * * * On Error GoTo 0

* * * * If TestStr = "" Then
* * * * * * 'keep looking
* * * * Else
* * * * * * UseThisFile = myStr
* * * * * * Exit For
* * * * End If
* * Next dCtr

* * If UseThisFile = "" Then
* * * * MsgBox "No files found"
* * Else
* * * * Set CSVWks = Workbooks.Open(Filename:=myStr).Worksheets(1)
* * * * With CSVWks
* * * * * * 'do lots of formatting???
* * * * End With
* * * * MsgBox "It's open!"
* * End If

End Sub

KurtB wrote:

Every day a report is posted online that I need to open; the report is
titled 080906_rpts_open.csv. Each morning I need to open the previous
days report or reports from over the weekend. I'm looking to write a
macro that would automatically open the report or reports based on how
many days I need to go back.
Thanks!


--

Dave Peterson


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to code VBA or else to open Excel and run Macro as Daily routi Ale Excel Discussion (Misc queries) 4 November 8th 07 05:34 PM
daily cash report dave Excel Worksheet Functions 1 October 16th 07 04:44 PM
Auto update daily report problem SteveG Excel Discussion (Misc queries) 4 February 9th 06 08:25 PM
How do i make my 'daily report' form into a functional spreadshee. proxymoron75 Brenda Excel Worksheet Functions 1 October 7th 05 01:59 AM
how do i create a daily income report (i'm a waitress) NayNae New Users to Excel 2 February 8th 05 09:57 PM


All times are GMT +1. The time now is 08:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"