Hi all,
Very new to VBA and trying to learn as I use it. I have searched for this extensively and found a few instances that seem get close to what I need to do, but I still do not know enough to be able to adapt them to my needs.
Basically, what I would need is a macro to import data from one or more closed CSV files on my computer to an open workbook. This could happen in one of two ways:
Preferred macro:
1. Pick one or more source CSV files from a specified folder through an Open File dialogue (ideally already pointing to the right folder, which never changes).
2. Copy cell E1 and range C1:C48 from Source1 and paste (values only) into A1 and A2:A49 of the destination file, respectively.
3. Reiterate the process for each source file, moving to a different range in the destination file (i.e. paste E1 and C1:C48 from Source2 into B1 and B2:B49 of destination, then E1 and C1:C48 from Source3 into C1 and C2:C49 of destination, etc)
The macro should be able to be linked to a button (i.e. shapes, form controls or activex controls)
Optional:
I only have 10 ranges available in the destination file (i.e. columns A to E and I to M) so ideally the macro should only allow for up to ten iterations and always only use the available ranges (if, say, columns A an H have already been used), stopping when column M has been filled. This probably overcomplicates things, so a standard "fill A to E and I to M" based on how many sources are selected" will also work.
Alternative macro:
As 1-3 above, but each range (column) in the destination file could have its own macro(button) so that one source file can only be imported in one range.
I would love to see an example of each option and it would be great if the macro could be easy to understand so I can see what's going on and learn from or adapt it as needed
Very new to VBA and trying to learn as I use it. I have searched for this extensively and found a few instances that seem get close to what I need to do, but I still do not know enough to be able to adapt them to my needs.
Basically, what I would need is a macro to import data from one or more closed CSV files on my computer to an open workbook. This could happen in one of two ways:
Preferred macro:
1. Pick one or more source CSV files from a specified folder through an Open File dialogue (ideally already pointing to the right folder, which never changes).
2. Copy cell E1 and range C1:C48 from Source1 and paste (values only) into A1 and A2:A49 of the destination file, respectively.
3. Reiterate the process for each source file, moving to a different range in the destination file (i.e. paste E1 and C1:C48 from Source2 into B1 and B2:B49 of destination, then E1 and C1:C48 from Source3 into C1 and C2:C49 of destination, etc)
The macro should be able to be linked to a button (i.e. shapes, form controls or activex controls)
Optional:
I only have 10 ranges available in the destination file (i.e. columns A to E and I to M) so ideally the macro should only allow for up to ten iterations and always only use the available ranges (if, say, columns A an H have already been used), stopping when column M has been filled. This probably overcomplicates things, so a standard "fill A to E and I to M" based on how many sources are selected" will also work.
Alternative macro:
As 1-3 above, but each range (column) in the destination file could have its own macro(button) so that one source file can only be imported in one range.
I would love to see an example of each option and it would be great if the macro could be easy to understand so I can see what's going on and learn from or adapt it as needed