Open specified source and destination files and copy single cell value, continue until all values copied

florelix

New Member
Joined
Aug 7, 2015
Messages
8
Hey guys,

I am facing an issue where my excel knowledge comes to an end. I already have a macro to get file names from a folder and rename the files according to a New File Name.

I now have one source file that contains a column with values. I need to copy each one of the values into a specified source file - each value goes into its own file, always into cell A4.

Source file: Values in column B starting in B2 and continuing down. Amount of rows varies.

Macro file:
- Has New File Name column.
- New file names are in column B starting with the first name in B3 and continuing down.
- Number of file names vary.
- New file name contains text and the exact value that is in source file column B.

Goal:
- Marco asks user to select source file. Source file is in same folder as target files.
- Macro takes first value from source file (B2) and finds corresponding target file in same folder. Macro opens target file and copies source value into target file cell A4. Macro closes target file.
- Macro continues with next value in source file (B3) and finds corresponding target file in same folder. Macro opens target file and copies source value into target file cell A4.
- This continues until all values in source file are copied.
- If source file has a value that does not have a corresponding target file, continue with next source file value.
- Generate output of all values copied in new sheet in macro file. Column A source file value. Column B statement of "Copied" or "Error" depending on whether value was copied successfully or not.


Example values and file names:
- Source value: 12345
- Target file name: ABC 12345 8ab abcd

Thank you so much for your help with this!
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Watch MrExcel Video

Forum statistics

Threads
1,102,578
Messages
5,487,668
Members
407,609
Latest member
stellaa9x

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top