Hi There
I am hoping someone can help me with this.. I know it should not be too complicated but my VB knowledge is purely from trial and error and not understanding.
What I want to do is the following (I want to run these steps as separate macros for simplicity and ease of faultfinding, and run them sequentially using 'Application.Run "nextmacroname" ' function):
Macro 1. In the main workbook (That houses the macros), a filepath and filename for a second workbook is given in cell A1 of sheet "DATA", and this is a variable ("c:\datafolder\130131.csv", which is derived from a formula and set to text format). The macro must open this second workbook (CSV opens as a workbook), and give an error message if the file is not found/ does not exist.
Macro 2. This macro must ensure that the second workbook (again, the workbook name based on the variable file name in cell A1 of main workbook) is active [being a csv file format, it has only 1 worksheet with same name as the workbook itself ("130131")... not sure if the worksheet would also need to be 'activated' in this case ], select the first 3 columns of data (columns A:C), copy these, and paste these into the first 3 columns of the "DATA" worksheet of the main workbook.
Macro 3. Close the second workbook (again, as before, workbook name based on the variable file name in cell A1 of main workbook), and ensure that any warnings are ignored (ie. 'do you want to save' , 'format may have changed' etc etc)
From here I would be able to manipulate the data that has just been 'imported'
What I have so far is the following:
Macro 1: Some coding that I found on the forum which seems to work perfectly for this step:
(dont actually know why this works when my sheet is named "DATA" but this just refers to 'Sheet1 when referring to cell A1)
Macro 2 & 3
I have no idea how to do these... any help would be greatly appreciated
Regards
Lang
Bookmarks