ThrottleWorks
Excel Ninja
Hi,
Hope everyone is healthy and doing fine.
I have one macro. This macro is throwing bug at 'With WorksheetName.QueryTables.Add' this particular activity.
Code is something like below. My apologies, code is at another networks hence I can not copy it.
With WorksheetName.QueryTables.Add(Connection:="TEXT;" & MyPathFullName, Destination:=WorksheetName.Range("A1"))
some lines of code here
.Refresh Background Query:= False 'I am getting bug at this line, path not found.
End With
MyPathFullName is defined in a cell. This is combination of Folder name, file name and date.
User changes the date as per the requirement. So user might change it from 29 to 30 June.
So example of a path would be MyFolder1/06302020/MyFileName
Only requirement from the user side is that user has to make sure particular folder is present at the location.
So if I select date at 30 June, then a sub folder named as 06302020 must be present in the MyFolder1.
Problem start here, user enters date as 07012020 by mistake. Folder for 07012020 is not present.
Runs the macro, macro throws a bug, 07012020 folder not found.
User corrects mistake, enters date as 06302020. Folder is present.
Runs the macro, but still same bug, 06302020 folder not found.
In the macro pop-up we can see it mentions correct folder name which is 06302020.
Still issue is there, I checked the code, MyPathFullName mentions correct path name.
If we close and re-open the macro, enter date as 06302020 then macro runs perfectly.
Not able to understand the issue. Can anyone please help me in this.
Hope everyone is healthy and doing fine.
I have one macro. This macro is throwing bug at 'With WorksheetName.QueryTables.Add' this particular activity.
Code is something like below. My apologies, code is at another networks hence I can not copy it.
With WorksheetName.QueryTables.Add(Connection:="TEXT;" & MyPathFullName, Destination:=WorksheetName.Range("A1"))
some lines of code here
.Refresh Background Query:= False 'I am getting bug at this line, path not found.
End With
MyPathFullName is defined in a cell. This is combination of Folder name, file name and date.
User changes the date as per the requirement. So user might change it from 29 to 30 June.
So example of a path would be MyFolder1/06302020/MyFileName
Only requirement from the user side is that user has to make sure particular folder is present at the location.
So if I select date at 30 June, then a sub folder named as 06302020 must be present in the MyFolder1.
Problem start here, user enters date as 07012020 by mistake. Folder for 07012020 is not present.
Runs the macro, macro throws a bug, 07012020 folder not found.
User corrects mistake, enters date as 06302020. Folder is present.
Runs the macro, but still same bug, 06302020 folder not found.
In the macro pop-up we can see it mentions correct folder name which is 06302020.
Still issue is there, I checked the code, MyPathFullName mentions correct path name.
If we close and re-open the macro, enter date as 06302020 then macro runs perfectly.
Not able to understand the issue. Can anyone please help me in this.