I need some VBA code that will open a text file in a know location (path) and find that file based on a variable number found in the wordbook Tab1. Once the text file is open I want the contents copied and then pasted into A1 of another tab.
The attached samples will help you understand what I am doing. The file named: CopyPasteTextFileData.xlsx is where the VBA code will reside. I want the VBA code to use the number found in the specific cell B4 on Tab1 of the workbook. Use that number in cell B4 to open the second attached file: Output"number".txt , where the "number" is the value in Cell B4. Once the text file is found, open it, select the entire contents of the file, copy it and paste it starting at cell A1 of Tab2 of the Workbook. If the code cannot find the exact text file it just returns and error message "Cannot find Output"number".txt.
The text file is in this path: C:\Users\Bob\Documents\TextFiles
The sample text file is Output123456.txt where the "123456" is the variable found in cell B4 of the Tab1 tab.
Thanks in advance!!
Bookmarks