Hi, I'm trying to make my code change the format of 9 columns. they all have the same amount of rows but these may differ each time the macro runs. I tried the following code with an array, but it doesnt work at all. Can you please help me to adjust it 'till it works? and maybe tell me what I did wrong?
Thanks in advance.
Also, this is all the code I use for this function so nothing else in "option explicit"![]()
Function Format_all() Dim wsO as worksheet Dim f As Long Dim format() As String For f = 1 To 9 Set format(1) = wsO.Range("A16:A" & wsO.Range("A16").End(xlDown).Row) Set format(2) = wsO.Range("B16:B" & wsO.Range("B16").End(xlDown).Row) Set format(3) = wsO.Range("C16:C" & wsO.Range("C16").End(xlDown).Row) Set format(4) = wsO.Range("D16:D" & wsO.Range("D16").End(xlDown).Row) Set format(5) = wsO.Range("E16:E" & wsO.Range("E16").End(xlDown).Row) Set format(6) = wsO.Range("F16:F" & wsO.Range("F16").End(xlDown).Row) Set format(7) = wsO.Range("G16:G" & wsO.Range("G16").End(xlDown).Row) Set format(8) = wsO.Range("H16:H" & wsO.Range("H16").End(xlDown).Row) Set format(9) = wsO.Range("I16:I" & wsO.Range("I16").End(xlDown).Row) With format(f).Borders(xlEdgeLeft) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlMedium End With With format(f).Borders(xlEdgeTop) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlMedium End With With format(f).Borders(xlEdgeBottom) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlMedium End With With format(f).Borders(xlEdgeRight) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlMedium End With Next f end function











LinkBack URL
About LinkBacks
Register To Reply
Bookmarks