Basically in your existing code you can replace text such as With ActiveSheet.QueryTables.Add(Connection:= _
[red]"TEXT;C:\..\u_S_07Oct2008.csv"[/red] _
, Destination:=Range("A1"))
.Name = [red]"u_S_07Oct2008"[/red]
with variables containing the text string.
Further you can construct the text string by joining individual bits of text using the & operator.
mintjulep has illustrated this by joining (="concatenating") two string variables - MyPath and MyDate.
Other examples:
MyFileName = "C:\..\A p\ACA S " & MyDate & ".xls"
(joining text with text in a variable)
You can also modify the content of an existing variable as in my equivalent to mintjulep's solution:
MyFilePath = "C:\..\A p\"
MyFileName = "ACA S " 'the first static bit of the name
MyFileName = myFileName & MyDate 'modify to include the date obtained via Inputbox earlier in the procedure
MyLongFileName = MyFilePath & MyFileName & ".xls"
MyFileName = MyFileName & ".xls"
In mintjulep's solution MyFilePath is not in fact the filepath but includes the first part of the filename. This in my view can cause confusion down the line when someone else is trying to understand your code. Put the first two rows of code at the beginning of the procedure so they are easily found when you need to modify them
Both of ur codes work. it does save mith the variable i have given .
but gavin in the above message u gave me that:
Basically in your existing code you can replace text such as With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\..\u_S_07Oct2008.csv" _
, Destination:=Range("A1"))
.Name = "u_S_07Oct2008"
with variables containing the text string.
So i just need to change it from
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\..\u_S_07Oct2008.csv" _
, Destination:=Range("A1"))
.Name = "u_S_07Oct2008"
to what
thanks a lot both of u
i really appreciate for ur time....
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.