I guess I need more macr training in Excel? What I could
do if anyone know how would be to have the macro auto
create this file and a auto run batch file rename this
file to the machine date and then another macro in Access
be able to delete the range that was just exported? My
problem is if I don't manually daily run this then after a
weekend I get more data than just one day. For example I
get 13248 lines of data per day. I then export to text
files for archiving and delete the data from the database.
The text files are then used in a variety of uses
primarily Excel. If I do not delete the data from Access
once exported you can imagine the size of the database in
a weeks time? I am auto importing right now and am looking
for a way to auto export and delete the data once exported.
[Snip]
OK. I can help with the Excel macro, but there are folks around here much
better at Access ones. ;-)
Excel macro follows.
Sub Macro1()
'
' This macro inserts a new worksheet, names it with the system date & time and
' copies data from a worksheet output with a "standard" name by MS Access
Dim AccessSheetName As String
Dim DateStr As String
Dim NewSheetName As String
AccessSheetName = "<Whatever it's called>"
DateStr = Str(Now)
'Puts current date & time into a string
' The next 3 lines turn the date & time from "DD/MM/YYYY HH:MM:SS" to '
' "YYMMDD_HHmmSS"
NewSheetName = Mid(DateStr, 9, 2) & Mid(DateStr, 4, 2) & Left(DateStr, 2)
NewSheetName = NewSheetName & "_" & Mid(DateStr, 12, 2)
NewSheetName = NewSheetName & Mid(DateStr, 15, 2)& Right(DateStr, 2)
Sheets.Add
'Adds a new worksheet at the front of the workbook
ActiveSheet.Name = NewSheetName
'Renames the new sheet to date & time as above
'This bit copies the Access output sheet
Worksheets(AccessSheetName).Activate
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Range("A1").Select
'This bit pastes the data to the new sheet
Worksheets(NewSheetName).Activate
Cells.Select
ActiveSheet.Paste
Range("A1").Select
End Sub
(You'll need to replace "<Whatever it's called>" with the real name - in
quotes but without the "<" & ">")
Hope this is some help towards your desired end.
--
John Thow
an optimist is a guy/ that has never had/ much experience -
certain maxims of archie; Don Marquis.
To e-mail me, replace the DOTs in the Reply-To: address with dots!