I work on some handful of excels everyday. For some files I need to fill Column A until multiple or single data available in Column B(usually from B2 the datas will be available as B1 could be a header row). and if no data available in a sheet the macro should move for the next file without throwing any error. what would be the code for the same. got failed with multiple codes.
The following code will loop through all the worksheets of the open workbooks and fill the column A with what is there in cell A2 on those sheets.
Dim wb As Workbook
Dim ws As Worksheet
Dim lr As Long
Application.ScreenUpdating = False
For Each wb In Application.Workbooks
For Each ws In wb.Worksheets
lr = ws.Cells(Rows.Count, "B").End(xlUp).Row
ws.Range("A2:A" & lr).Value = ws.Range("A2").Value
Application.ScreenUpdating = True