alansidman
09-18-2015, 07:36 PM
Been looking at this and cannot see my issue.
Option Explicit
Sub works()
Dim i As Integer, c As Range
Dim Path As String, File As String
Dim wkb As Workbook
For i = 1 To 3
Path = " C:\Users\Alan\Desktop\Works" & i & "\"
Set wkb = Path & Workbooks("Works" & i & ".xlsx")
c = wkb.Sheets("Sheet1").Range("A1")
Workbooks.Open wkb
c.Value = i
ActiveWorkbook.Close
Next i
End Sub
Getting Error Message "Subscript Out of Range" on this line
Set wkb = Path & Workbooks("Works" & i & ".xlsx")
Have checked file names to ensure that they are named correctly. Folders are named correctly. What am I missing here?
Alan
Option Explicit
Sub works()
Dim i As Integer, c As Range
Dim Path As String, File As String
Dim wkb As Workbook
For i = 1 To 3
Path = " C:\Users\Alan\Desktop\Works" & i & "\"
Set wkb = Path & Workbooks("Works" & i & ".xlsx")
c = wkb.Sheets("Sheet1").Range("A1")
Workbooks.Open wkb
c.Value = i
ActiveWorkbook.Close
Next i
End Sub
Getting Error Message "Subscript Out of Range" on this line
Set wkb = Path & Workbooks("Works" & i & ".xlsx")
Have checked file names to ensure that they are named correctly. Folders are named correctly. What am I missing here?
Alan