Current location - Recipe Complete Network - Complete cookbook - Help, use vba to realize automatic batch copying and modify saved files.
Help, use vba to realize automatic batch copying and modify saved files.
Code is in the file module, or paste the following code into the module.

Child write data ()

wbpath = ThisWorkbook。 Path and path. "\"

Template file address = wbpath &; "Template file"&; "\"

to folder = WB path &; "Copy the generated table to this folder"&; "\"

My_file = Dir (template file address)

When my file & lt& gt ""

Workbooks. Open file name: = template file address &; My file

Use this workbook

data _ row = . active sheet . range(" A " & amp; Ok. Count). End (xlUp). row

For i = 2 to data_row

? If Val(.ActiveSheet.Cells(i,4)) = Val(Split(ActiveWorkbook。 Name, "") (0)) and then

ActiveWorkbook。 active sheet . Range(" F2 ")= = active sheet . cells(I,3)。 value

Activeworkbook.saveasfilename: = to the folder &; active sheet . range(" B " & amp; I) and amp".xlsx "

ActiveWorkbook。 Closed leave

? If ... it will be over.

Next, I

End with ...

My Files = Directory

ring

End joint