Macro Error

  • Thread starter Thread starter Krefty
  • Start date Start date
K

Krefty

I have the following Macro (BELOW) in a workbook. It
works in opening the daily updated
workbook "degreedays.xls" but what I want is this workbook
to open in another workbook when the user runs the macro
on the worksheet "Weather" in the ddays.xls workbook.

Thanks in advance for looking at my problem.

Krefty

Option Explicit
Sub Macro1()

Dim destCell As Range
Dim degreedays As Workbook

With Workbooks("ddays.xls").Worksheets("Weather")
.UsedRange.Clear
Set destCell = .Cells(.Rows.Count, "A").End
(xlUp).Offset(1, 0)
End With

Workbooks.OpenText
Filename:="G:\Gas_Control\EXCEL\DEPT\Month
Reports\degreedays.xls", _
Origin:=xlWindows, _
StartRow:=1, DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(8, 1), _
Array(30, 1), Array(41, 1), Array(67, 1), Array
(78, 1))






End Sub
 
Sub Macro1()

Dim destCell As Range
Dim degreedays As Workbook

With Workbooks("ddays.xls").Worksheets("Weather")
.UsedRange.Clear
Set destCell = .Cells(.Rows.Count, "A").End
(xlUp).Offset(1, 0)
End With

Workbooks.OpenText
Filename:="G:\Gas_Control\EXCEL\DEPT\Month
Reports\degreedays.xls", _
Origin:=xlWindows, _
StartRow:=1, DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(8, 1), _
Array(30, 1), Array(41, 1), Array(67, 1), Array
(78, 1))
ActiveSheet.Range("A1").CurrentRegion.Copy _
Destination:=destCell
ActiveWorkbook.Close Savechanges:=False

End Sub

Regards,
Tom Ogilvy
 
Back
Top