Hello,
I have a workbook with a button that does the following: User downloads an excile file from the internet, then activates a workbook i created that has a button, that basically copies all the info on the downloaded file to it. The button on a workbook has the following code:
On Error GoTo ErrMsg
With Workbooks("randsf[1].xls").Worksheets(1)
.Range("A2", .Range("A" & Rows.Count).End(xlUp)).Resize(, 15).Copy _
Destination:=ActiveWorkbook.Sheets("Sheet2").Range("A2")
End With
Exit Sub
ErrMsg:
MsgBox ("There is no randsf workbook curently open")
End Sub
The problem is that the "randsf" workbook is a temporary file downloaded from the internet that is only named "randsf[1]" if it's the first file downloaded by the user since starting their computer, otherwise it could be named randsf[6], and the user will then get the error message.
Obviously i've found that it's not as simple as changing the reference to "randsf*", and i've also tried the following (found online sometime ago??) with no success:
On Error GoTo ErrMsg
' If InStr(1, name, "randsf[") > 0 Then
' With ActiveWorkbook.Worksheets(1)
' .Range("A2", .Range("A" & Rows.Count).End(xlUp)).Resize(, 15).Copy _
' Destination:=ActiveWorkbook.Sheets("Sheet2").Range("A2")
' End With
'End If
Any help would be appreciated. This is an issue that has reared i's ugly head every couple months for the last year or so, and just cant seem to figure it out.
Bookmarks