LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Runtime Error 1004???

I have the following code in a module saved as an Add-in. I wanted this
add-in to be activated everytime an excel file is open. When I run this code
while a file is open in the VBA editor, the code works fine. But when I open
a file, the error "Worksheets of object global failed 1004" pops up. I
removed the "Worksheets("data").activate" line to see if it would run but
then the error msg reads "Columns of object global failed 1004". I then
removed the first call hide_cols() and the error msg reads "Cells of object
global failed 1004". I've been searching for clues on the web still cant get
it to work. Any suggestions or help would be greatly apprectiated thanks.

Sub Auto_open()

Worksheets("Data").Activate

Call Hide_cols
Call Format_cols
Call Filter_SM
Call Page_Setup


End Sub
Sub Hide_cols()

Dim i As Integer

For i = 26 To 1 Step -1
If (i < 2) And (i < 3) And (i < 5) And (i < 6) And (i < 9) And (i <
15) And (i < 24) Then
Columns(i).Select
Selection.EntireColumn.Hidden = True
End If
Next i

End Sub

Sub Format_cols()

Cells(1, "X").Value = "SsC"
Cells(1, "O").Value = "SL"
Cells(1, "E").Value = "AWS"
Cells(1, "I").Value = "BOH"
Cells(1, "AA").Value = "Pickbin"
Cells(1, "AB").Value = "SGF"
Cells(1, "AC").Value = "Diff+/-"
Range("E1:AC1").HorizontalAlignment = xlHAlignCenter
Cells(1, "AC").Font.Bold = True


With Worksheets("Data")
.Columns("O").NumberFormat = "00-00-00"
.Columns("B").AutoFit
.Columns("E").AutoFit
.Columns("O").AutoFit
.Columns("X").AutoFit
.Columns("I").AutoFit
.Columns("AA:AC").ColumnWidth = 9
.Columns("C").ColumnWidth = 39.3
End With

End Sub

Sub Filter_SM()

Columns("F").AutoFilter Field:=1, Criteria1:="=2"
Columns("F").Select
Selection.EntireColumn.Hidden = True

End Sub

Sub Page_Setup()

With Worksheets("Data").PageSetup
.CenterHeader = Format(Now(), "mmmm dd, yyyy")
.RightHeader = "page &p"
.CenterHorizontally = True
.Zoom = 125
.Orientation = xlLandscape
.PrintGridlines = True
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(0.51)
.BottomMargin = Application.InchesToPoints(0.35)
.HeaderMargin = Application.InchesToPoints(0.2)
.FooterMargin = Application.InchesToPoints(0.2)
.PrintTitleRows = ActiveSheet.Rows(1).Address

End With

End Sub
 
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
runtime error 1004 HELP PLS Marcelo P Excel Discussion (Misc queries) 2 May 23rd 07 08:56 PM
Runtime Error '1004' [email protected] Excel Discussion (Misc queries) 2 July 18th 05 06:10 AM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Runtime Error '1004' Dean[_4_] Excel Programming 2 January 9th 05 09:02 PM
Runtime error 1004 Gary[_4_] Excel Programming 1 October 10th 03 02:21 PM


All times are GMT +1. The time now is 04:26 PM.

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

About Us

"It's about Microsoft Excel"