There are probably hundreds of posts on this error and each one is different. I am trying to open files and put some data in another file. I don't want to have to manually open all of them because there is something like 450 of them. So I came up with this code and I am getting the above error on the first "range =" and I am guessing that I will get it on the second one also. Here is the code.
Sub ClosedClaims()
Dim i As Long
Dim st As Range
Dim it As Range
Set st = Range("State")
Set it = Range("InjType")
Workbooks.Open Filename:= _
"I:\WC\CVM\Exposure Curves Project\Distributions\Output\Closed\" & st & "_" & it & "_Closed ($1B claims removed)v4.xlsm"
Windows("Combined output.xlsm").Activate
Range("B12").Select
For i = 12 To 1962
Range("B" & i).Formula = "='[" & st & "_" & it & "_Closed ($1B claims removed)v4.xlsm]for R'!" & Range("B" & i)
Range("C" & i).Formula = "='[" & st & "_" & it & "_Closed ($1B claims removed)v4.xlsm]for R'!" & Range("C" & i)
Next i
Windows(st & "_" & it & "_Closed ($1B claims removed)v4.xlsm").Activate
ActiveWindow.Close
Windows("Combined output.xlsx").Activate
Range("B12").Select
End Sub
I will be adding the other parts once I get this down.
Also if anyone has a better idea on how to do this that would be great also. As far as I can tell the ranges will all be the same B12:C1962.
Thanks in advanced
Dave
Sub ClosedClaims()
Dim i As Long
Dim st As Range
Dim it As Range
Set st = Range("State")
Set it = Range("InjType")
Workbooks.Open Filename:= _
"I:\WC\CVM\Exposure Curves Project\Distributions\Output\Closed\" & st & "_" & it & "_Closed ($1B claims removed)v4.xlsm"
Windows("Combined output.xlsm").Activate
Range("B12").Select
For i = 12 To 1962
Range("B" & i).Formula = "='[" & st & "_" & it & "_Closed ($1B claims removed)v4.xlsm]for R'!" & Range("B" & i)
Range("C" & i).Formula = "='[" & st & "_" & it & "_Closed ($1B claims removed)v4.xlsm]for R'!" & Range("C" & i)
Next i
Windows(st & "_" & it & "_Closed ($1B claims removed)v4.xlsm").Activate
ActiveWindow.Close
Windows("Combined output.xlsx").Activate
Range("B12").Select
End Sub
I will be adding the other parts once I get this down.
Also if anyone has a better idea on how to do this that would be great also. As far as I can tell the ranges will all be the same B12:C1962.
Thanks in advanced
Dave