How to join columns of a table without continuity

Brass Contributor
Good afternoon. I want to format a set of columns in a table, which are not together.
I'm using this code, but I get an "Application definition or object definition error" error and I can't get over it. Thanks

 

 

With Folha21.ListObjects(1).DataBodyRange
.Columns.Range("A:I,M,P,S,V,X:AF,AT,AV,AX,AZ,BA,BD:BE,BH,BL:BP,BS,BV,BY").NumberFormat = "@"
End With​

 

 

3 Replies

@csoares 

You have to write the single-column ranges in C:C format:

With Folha21.ListObjects(1).DataBodyRange
.Columns.Range("A:I,M:M,P:P,S:S,V:V,X:AF,AT:AT,AV:AV,AX:AX,AZ:AZ,BA:BA,BD:BE,BH:BH,BL:BP,BS:BS,BV:BV,BY:BY").NumberFormat = "@"
End With

Also, I don't think you need .Columns in there.

I still receive the same error

@csoares 

Could you attach a sample workbook without sensitive information?