简体   繁体   中英

Change text color, unbold and size

I hope everyone is well. I need some help regarding with my macro code. What I want is to have a macro code that will change the font size, color and un-bold on specific sheets from a2-w2 or until the last row that contain data. I'm not sure what needs to be done, I know I can change the range to a2-w350, but what if there is more rows than 350. Is there a way to change it until the last row data?

[Sub format()
with worksheet("Temp").Range("A2:w2")
.Font.size = 11
.Font.Color = vbBlack
.Font.Bold = False

end with
end sub]

Try this (not tested)

sub format()
with worksheet("Temp")
With .Range("A2:w" & .UsedRange.Rows.Count) 'Fixed

.Font.size = 11
.Font.Color = vbBlack
.Font.Bold = False

End With
end with
end sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM