0

I receive a file with 89 tabs. I want to loop through them and insert the name of the tab in the column M for the same number of rows that are not blank in column A.

I tried this code :

Sub column_m()

Dim ws As Worksheet
Dim x As Integer
Dim numrows As Integer


For Each ws In ThisWorkbook.Worksheets
       
    numrows = ws.Range("A1", Range("A1").End(xlDown)).Rows.count
           
    For x = 1 To numrows
        Cells(x, 13) = ws.Name
       
    Next x
Next ws
End Sub

It works on my first ws but I get an error 400 and no data entry after my first one. Any suggestion?

grigri
  • 65
  • 5

0 Answers0