This workbook contains two main macros plus one for cleaning. Below I enumerated the actions that the two main macros perform when they are executed.
- Show the file dialog and wait to select a text file.
- Open the text file and read the headings (first line).
- Add data validation and conditional formatting for the column selection (mainsheet).
- Format the main sheet.
- Check the file path.
- Check which columns are being selected.
- Get the name of the text file.
- Add a new temporary sheet.
- Import the text file into the temporary sheet.
- Create a new sheet based on the text file’s name.
- Copy the selected columns to the new sheet.
- Format the new sheet and delete the temporary sheet.
The above approach might not be straightforward but is quite fast. I have also tried an alternative method to import the data. The LoadDataAlternatively macro reads the data line by line (using Line Input command) and writes only the selected columns to the spreadsheet. However, it was considerably slower than the approach I finally followed (LoadData), so I did not include it in this workbook.