Dick7Access
Dick S
- Local time
- Today, 05:58
- Joined
- Jun 9, 2009
- Messages
- 4,298
How to import a MS Excel spread sheet Definition. Can’t find anything on Google.
I often import a DB in access with just the forms, tables so on but without the data. Its call definition only I am assuming Excel has the same thing. I have a few spread sheets that I use every year. Instead of building a new spread sheet or copying last years and save the time of putting in all the headers and code, I was assuming I could import last years without data.what is spreadsheet Definition?
column structure and type?
10 times longer. Why is it we never have time to do something right away, but have time to do itn10 times longer?Hardly?
You save your existing 2021 file as an Excel template (xltx)
Then you clear this years data. Then you save it again. And close it.
Then you click New, My templates and select your template.
That is it, a few minutes work. The deletion of data will probably take you longer?![]()
That fact that you use an actual template.The four lines of data I left in so I could refresh my memory on the formulars, as I only use this SS one a year, and though it would not take too long to remove four lines of data. I have saved it to a folder called Templates. I did not know about the excel template option until you advised me. What is the advantage of the template option as opposed to the way I did it.
Sub ClearGCD()
' Clear trips sheet for next month
Dim iTotalsRow As Integer
'First find the Totals Row
Range("B1").Select
Columns("B:B").Select
Selection.Find(What:="totals", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
iTotalsRow = ActiveCell.Row - 1
ActiveSheet.Range("A4:E" & iTotalsRow).ClearContents
ActiveSheet.Range("G4:G" & iTotalsRow).ClearContents
ActiveSheet.Range("J4:J" & iTotalsRow).ClearContents
End Sub
Thanks, that is a big advantage. I am going to do it.That fact that you use an actual template.
So every time you want a new workbook based on that template, you get a copy automatically, no chance of overwriting the actual template, which you can do your way? The fact that you save it as a Template saves it to the common Templates folder, so you can find it via the GUI.
No guarantee you have the correct Templates folder?
I actually have to do this every month for my community work, but I just created some code, as I also want to copy that month's data to a master workbook, to keep track of all trips. Otherwise a template for that would be a good idea.
Columns with formulae I leave alone.
Code:Sub ClearGCD() ' Clear trips sheet for next month Dim iTotalsRow As Integer 'First find the Totals Row Range("B1").Select Columns("B:B").Select Selection.Find(What:="totals", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate iTotalsRow = ActiveCell.Row - 1 ActiveSheet.Range("A4:E" & iTotalsRow).ClearContents ActiveSheet.Range("G4:G" & iTotalsRow).ClearContents ActiveSheet.Range("J4:J" & iTotalsRow).ClearContents End Sub
The four lines of data I left in so I could refresh my memory on the formulars, as I only use this SS one a year, and though it would not take too long to remove four lines of data. I have saved it to a folder called Templates. I did not know about the excel template option until you advised me. What is the advantage of the template option as opposed to the way I did it.