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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple task for VBA superstar :)

Status
Not open for further replies.

daggg011

Programmer
Jun 26, 2020
5
0
0
RS
I have a txt file with 3 columns.

1st column: cityid1

2nd column: cityid2

3rd column: distance between cityid1 and cityid2

My question is... How I can read that data from txt file, have one dropdown list (choose 1st city), then based on that dropdown, choose second dropdown list (choose a city), and then get the distance as the final result.

Thank you very much for reading this, and help.
 
 https://files.engineering.com/getfile.aspx?folder=87696ead-5345-44f2-b7aa-cb5aa40cb329&file=1.txt
Hi,

There's a really easy way to get your answer using a native Excel Feature inherent to Excel 2007+.

IMPORT your file and use the dropdown filters you get on IMPORT.

BTW, VBA implies that some application, like Excel for instance, is open and running some code. Hence my suggestion in paragraph 1 & 2 above.

BTOW, I do have a VBA, SQL solution. THE VBA is required only to assure any Path and Workbook Name. It uses native Excel features of MS Parameter Query and Data Validation drop down boxes.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Can you please, show me/send to me VBA solution...

I'm familiar with Excel etc...

I need to have VBA form, code...

Thank you very much.
 
I will walk you through the process.

First, IMPORT your text file into an empty sheet of your workbook.
1) Add your field headings to Row 1, starting in column A
[tt]cityid1
cityid2
distance[/tt]

2) via Data > Get external data > From TEXT files... and drill down to your text file and follow the steps in the IMPORT wizard.
3) name this sheet IMPORT

When you get that done, add a sheet named QUERY and a sheet named DASHBOARD with three columns:
[tt]cityid1
cityid2
distance[/tt]

SAVE your workbook as a Macro Enabled Workbook

Post back for the next step.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Thank you very much for the help so far...

But, I don't need solution that is excel related...

I need it all done in microsoft visual studio...

Code+Form... That's it.

Or, I am wrong...

Once again, thanks for the help & support.
 
>Simple task for VBA superstar
>I need it all done in microsoft visual studio...

Er ... VBA and Visual Studio have pretty much nothing to do with each other. Or do you mean VBA IDE?

(In other words, are you looking for a VB.NET solution or a VBA solution?
 
Yes! My bad!

I am so sorry for this misunderstanding...

Can you do it?

Thank you.
 
You, daggg011, sound to me just like a user I've encountered on several occasions.

This is not a free coding service. The site is Tek-Tips, with the emphasis on Tips.

BTW, you didn't even bother to reply to strongm's two questions before asking for a handout, as usual.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Like, I said... I needed help,and support...It's all crystal clear.

Don't know what's wrong with that...
 
Sounds like a homework to me.
This is what my teacher asked for, I don't want to lift a finger, so give me ready to use code or I will get very upset about any other response and refuse to answer any questions.

We've been here before....

strongm said:
are you looking for a VB.NET solution or a VBA solution?

daggg011 said:
Yes! My bad!

It's all crystal clear.

No, it is not clear at all [hairpull]

---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top