How to Loop through tables in sheets

  • I have some code to trim some columns in each table in my workbook. It's supposed to go to each table and just trim the values, but the problem when I run the code is that it copies the values from the range in the sheet I'm in when I run the code into that table's column. I don't know if I have to activate the sheet of each table when I'm running it maybe? My code is below:


    Code
    Set tbl_trim = Application.Range(TableName).ListObject
      Set rangeColumn = tbl_trim.ListColumns(HeaderName).DataBodyRange
    
    
    With rangeColumn
          .Value = Evaluate("if(row(" & .Address & "),clean(trim(" & .Address & ")))")
    End With


    Thanks!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!