Macro Error

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
 
T

Tom Ogilvy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top