Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP!!!!! ON CREATING A DIALOG BOX WHEN I RUN A MACRO 3

Status
Not open for further replies.

lvr5555

Programmer
Oct 15, 2008
13
US
Please need help in VBA. When i run a macro how can i open a dialog box with some data.

need urgent.
thanks
 
Adding to Mintjulep's response:

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



Gavin
 
Thanks a lot for the reply's mintjulep and gavin.

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....
 
Guys got it. it is running

i have changed to the variables i gave
thanks a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top