S
Sharon
What I'm doing:
Replacing all the data in a worksheet with new data from
a .txt file.
The code I'm using (I'm refreshing two worksheets here):
Sub RefreshPensionWelfareData()
' Refresh Pension worksheet with the Pension .txt file.
Application.Goto Reference:="PensionData"
Selection.QueryTable.Refresh BackgroundQuery:=False
Application.CutCopyMode = False
Range("B1").Select
' Refresh the Welfare sheet with the Welfare.txt file.
Application.Goto Reference:="WelfareData"
Selection.QueryTable.Refresh BackgroundQuery:=False
Application.CutCopyMode = False
Range("B1").Select
End Sub
The question:
This is working but I am new to VBA and do not understand
how Excel knew which file is which or where it is without
showing the path to the file in any of the code above.
Is the code above an acceptable way of refreshing the
data? And is there a place in Excel where I can go to see
the SQL or where the path to the file is stored? I see
that if the path is changed I can go to Data, Get External
Data and Edit Text Import to navigate to the file.
Thanks,
Sharon
Replacing all the data in a worksheet with new data from
a .txt file.
The code I'm using (I'm refreshing two worksheets here):
Sub RefreshPensionWelfareData()
' Refresh Pension worksheet with the Pension .txt file.
Application.Goto Reference:="PensionData"
Selection.QueryTable.Refresh BackgroundQuery:=False
Application.CutCopyMode = False
Range("B1").Select
' Refresh the Welfare sheet with the Welfare.txt file.
Application.Goto Reference:="WelfareData"
Selection.QueryTable.Refresh BackgroundQuery:=False
Application.CutCopyMode = False
Range("B1").Select
End Sub
The question:
This is working but I am new to VBA and do not understand
how Excel knew which file is which or where it is without
showing the path to the file in any of the code above.
Is the code above an acceptable way of refreshing the
data? And is there a place in Excel where I can go to see
the SQL or where the path to the file is stored? I see
that if the path is changed I can go to Data, Get External
Data and Edit Text Import to navigate to the file.
Thanks,
Sharon