Here is the code that I eventually want to be able to run automatically on
the open of the file, through personal.xls... If this is even possible
Sub Workbook_Open()
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
mycount = Selection.Count
For j = mycount To 1 Step -1
If Cells(j, 1).Value = "Sales" Then
Exit Sub
Else
Rows(j).Select
Selection.Delete Shift:=xlUp
End If
Next j
End Sub
"JLGWhiz" wrote:
Error 91 is when an Object variable is not Set. If your code had been posted
someone could probably spot the problem.
"matt" wrote:
Hello,
I have an excel file that I get as an attachment everymonring with a table
in it. Every monring I save the attachment over the previous day's file.
If I open the document and then open the VB editor in the project explorer
on the left, there is two projects the first I believe Personal.xls and the
second is the attachment file that I was talking about.
I wanted to create a macro that runs on the open of the file using "Private
Sub Workbook_Open" but the problem is everytime I save the attachment, the
code for that file gets wiped out.
So I was trying to write a "Workbook_Open" under the
"Personal.xls"/"ThisWorbook". But the problem is when I open the file,
"personal.xls" project opens first then my files project opens. Now I think
It is trying to run this code before it open my files workbook, and dosen't
find it. I get an "Error 91" I click cancel, and then my file opens.
The code that I wrote works if I step through it in the VB Editor, but I get
the error on the open of the file.
Any thoughts?