ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Looping macro (https://www.excelbanter.com/excel-worksheet-functions/122427-looping-macro.html)

RK

Looping macro
 
Hi!,
Can this be simplified...any help is appreciated.

Sub Checking_the_Format()

Range("A1:H1").Select
For Each cel In Selection
If cel.Font.Bold = False Then cel.Font.FontStyle = "Bold"
Next cel

Range("A2:H2").Select
For Each cel In Selection
If cel.Font.Bold = False Then cel.Font.FontStyle = "Bold"
Next cel
' Done for 5 rows
End Sub

Thanks


Bob Phillips

Looping macro
 
Sub Checking_the_Format()
For Each cel In Range("A1:H5")
cel.Font.FontStyle = "Bold"
Next cel
End Sub


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"RK" wrote in message
ups.com...
Hi!,
Can this be simplified...any help is appreciated.

Sub Checking_the_Format()

Range("A1:H1").Select
For Each cel In Selection
If cel.Font.Bold = False Then cel.Font.FontStyle = "Bold"
Next cel

Range("A2:H2").Select
For Each cel In Selection
If cel.Font.Bold = False Then cel.Font.FontStyle = "Bold"
Next cel
' Done for 5 rows
End Sub

Thanks




Jim Cone

Looping macro
 
Sub Checking_the_Format()
Dim cel As Excel.Range
For Each cel In Range("A1:H5").Cells
cel.Font.Bold = True
Next cel
End Sub

'Even better...

Sub Checking_the_Format_R1()
Range("A1:H5").Font.Bold = True
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware




"RK"
wrote in message
Hi!,
Can this be simplified...any help is appreciated.
Sub Checking_the_Format()
Range("A1:H1").Select
For Each cel In Selection
If cel.Font.Bold = False Then cel.Font.FontStyle = "Bold"
Next cel

Range("A2:H2").Select
For Each cel In Selection
If cel.Font.Bold = False Then cel.Font.FontStyle = "Bold"
Next cel
' Done for 5 rows
End Sub
Thanks



All times are GMT +1. The time now is 08:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com