View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Macro creates additional datafiles when saving copies of workb

Hi Pete,

Rob Boveys's addin is *very* frequently recommended by the conoscenti in
this group.

Given your problems, I would advocate running the CodeCleaner *first*.

Including download, you will just about have time to drink a coffee - which
might also assuage your nerves!

---
Regards,
Norman



"Peter Rooney" wrote in message
...
Hi, Norman,

I'll take a look at it - AFTER I get this thing working again, and AFTER I
take 74 backup copies when it does..! :-)

Pete



"Norman Jones" wrote:

Hi Peter,

You might first like to download Rob Boveys CodeCleaner addin which is
freely downloadable at:

http://www.appspro.com/Utilities/Utilities.htm

Run the dwnloaded Exe file to invoke an automatic installation routine.
Call
the CodeCleaner from the Tools menu.


---
Regards,
Norman



"Peter Rooney" wrote in message
...
Norman,

I'm recreating the workbook as we speak.

Hopefully copying and pasting the code won't carry the corruption over.

I'll let you know how I go on

Thanks again

Pete



"Norman Jones" wrote:

Hi Peter,

I've been experiencing application errors all morning
with the workbook in question.

I think that I would try to recreate your workbook.

Do you think the fact that the workbook's
corrupted in some way might lead to the erroneous file being saved
at
the
same time as the proper one?

Corrupt workbooks can cause strange phenomenons. It would not surprise
me
if
your reported:

filename made up of 8 random alphanumeric characters.

was caused by corruption

When Excel saves a file it produces an intermediate, temporary copy
with
a
name such as you describe. It seems possible that this temporary copy
is
not being deleted.


---
Regards,
Norman



"Peter Rooney" wrote in
message
...
Norman,

Here it is, although I've been experiencing application errors all
morning
with the workbook in question. Do you think the fact that the
workbook's
corrupted in some way might lead to the erroneous file being saved
at
the
same time as the proper one?

Pete


Sub DefineDatabase()
Application.ScreenUpdating = False
Set DBSheet = Worksheets("Database")
Set DBStart = DBSheet.Range("DatabaseStart")
Set DBCR = DBStart.CurrentRegion

If DBCR.Rows.Count 1 Then
DBCR.Name = "Database"
DBStart.Offset(1, 0).Resize(DBCR.Rows.Count - 1,
DBCR.Columns.Count).Name = "Data"
DBStart.Offset(1, 0).Resize(DBCR.Rows.Count - 1, 1).Name =
"PrefixColumn"
DBStart.Offset(1, 7).Resize(DBCR.Rows.Count - 1, 1).Name =
"CategoryColumn"
DBStart.Offset(1, 9).Resize(DBCR.Rows.Count - 1, 1).Name =
"GroupColumn"
DatabaseSize = DBCR.Rows.Count - 1

'-----------------------------------------------------------------------------------------
'You need this in order for the validation routines to work
correctly!
'You also need to do it if you want to set up a scrollarea
FirstCellAddress = DBStart.Offset(1, 0).Address
FinalCellAddress = DBStart.Offset(DBCR.Rows.Count - 1,
DBCR.Columns.Count - 1).Address
FirstDBRow = DBStart.Offset(1, 0).Row
FirstDBColumn = DBStart.Offset(1, 0).Column
FinalDBRow = DBStart.Offset(DBCR.Rows.Count - 1,
DBCR.Columns.Count
- 1).Row
FinalDBColumn = DBStart.Offset(DBCR.Rows.Count - 1,
DBCR.Columns.Count - 1).Column

'-----------------------------------------------------------------------------------------
Else 'set up single row "Data", "PrefixColumn", "CategoryColumn"
and
"GroupColumn" ranges
DBStart.Offset(1, 0).Resize(1, DBCR.Columns.Count).Name =
"Data"
DBStart.Offset(1, 0).Resize(1, 1).Name = "PrefixColumn"
DBStart.Offset(1, 7).Resize(1, 1).Name = "CategoryColumn"
DBStart.Offset(1, 9).Resize(1, 1).Name = "GroupColumn"
DatabaseSize = 0
End If
'MsgBox (DBFormatCallLocator & " - There is/are " & DatabaseSize
& "
row(s) in this database" & vbCrLf & vbCrLf & _
"First Row: " & FirstDBRow & vbCrLf & _
"Final Row: " & FinalDBRow & vbCrLf & _
"First Column: " & FirstDBColumn & vbCrLf & _
"Final Column: " & FinalDBColumn)

'CellsToAllow = FirstCellAddress & ":" & FinalCellAddress
'MsgBox (CellsToAllow)
'DBSheet.ScrollArea = CellsToAllow
End Sub

Sub YearWeekResourceName()
Set WeekNumber = DBSheet.Range("WeekNumber")
Set Year = DBSheet.Range("Year")
Set ResourceName = DBSheet.Range("ResourceName")

End Sub