Batch file processing. Macros should be placed in the general module of any book.
Next to this book to place the folder files2000 , in which to place all the files intended for processing. The path to the folder and its name can be selected by changing the line of code.
sPath = ThisWorkbook.Path & "\files2000\"
Ranges are set in the lines
.Range("B2:B" & lRw).Value = dValue .Range("C2:D" & lRw).ClearContents
The value to add to the range of column B is given by a constant. You can without it - write the value in the string
.Range("B2:B" & lRw).Value = 0.3
Macro
Sub DataChange() Dim wBook As Workbook Dim sPath As String Dim sFName As String Dim lRw As Long Const dValue As Double = 0.3 With Application: .ScreenUpdating = False: .DisplayAlerts = False: End With sPath = ThisWorkbook.Path & "\files2000\" sFName = Dir(sPath & "*.xls*", vbDirectory) Do While sFName <> "" Set wBook = Workbooks.Open(Filename:=sPath & sFName) With wBook With .Worksheets(1) lRw = .Cells(.Rows.Count, 1).End(xlUp).Row If lRw > 1 Then .Range("B2:B" & lRw).Value = dValue .Range("C2:D" & lRw).ClearContents wBook.Save End If End With .Close End With sFName = Dir Loop With Application: .ScreenUpdating = True: .DisplayAlerts = True: End With MsgBox "OK", 64, "" End Sub
Definition of the last line
.Cells(.Rows.Count, 1).End(xlUp).Row - последняя видимая заполненная ячейка столбца А
All lines must be expanded in the files being processed (filters removed, if any), otherwise the range of lines may be determined incorrectly.
Find the lower limit by the size of the custom range (we assume that row 1 contains the table header):
lRw = .UsedRange.Rows.Count
The disadvantage of this option is that all formatted strings will fall into the range, including those without data (this is often found with incompetent copying: 10 lines are filled, and the range is by a million).
The range of filled lines relative to the cell:
lRw = .Range("A1").CurrentRegion.Rows.Count
At the same time, there must be confidence that the data range is inseparable (data is not separated by empty lines and columns).