D
D
dao82019-06-19 11:48:07
Macros
dao8, 2019-06-19 11:48:07

How to import the contents of multiple .txt files into individual cells in an Excel document?

Good afternoon.
Given at the beginning:
- many .txt files (hundreds) named "1.txt", "2.txt", "3.txt", etc. Each file contains a small unique text.
- an Excel document with a listed list of names of available .txt files (all file names are listed in column "A").
What you need to do :
Fill each cell in column "B" with the text contained in the .txt file with the name from the adjacent cell in column "A".
In other words: in the cell of column "A" - the name of the file, in the cell of column "B" - its contents.
I have no experience in creating macros or add-ons (so far I have only blindly used a few ready-made solutions downloaded from the net), so please explain like a child. I would also be grateful if you advise what to read in order to understand these intricacies.
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2019-06-19
@JohnnyBravo7

1. Find a simple loop written in VBA, understand how it works
2. Find an example of code for working with files: open, read, close
3. Find an example of code for copying information from a file to a cell
4. Combine the knowledge gained and write a script that will run through all the cells, open the file, read it, copy the contents to another cell, close the file, go down to the cell below and start all over
again

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question