Change Row to Bold Between a range

DaveRadford

Board Regular
Joined
Feb 18, 2010
Messages
63
Afternoon All,

I wanted to change the whole row to bold between a range if a cell had selected within in and unbold the previous cell. You will see from my code that it is working. However i was looking to see if anyone had a neater way of doing it? If cludged mine together to make a working solution but it is very messy.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Range("B11:T46").Font.FontStyle = "Regular"

If Not Intersect(Target, Range("B11:T11")) Is Nothing Then
Range("B11:T11").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B12:T12")) Is Nothing Then
Range("B12:T12").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B13:T13")) Is Nothing Then
Range("B13:T13").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B14:T14")) Is Nothing Then
Range("B14:T14").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B15:T15")) Is Nothing Then
Range("B15:T15").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B16:T16")) Is Nothing Then
Range("B16:T16").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B17:T17")) Is Nothing Then
Range("B17:T17").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B18:T18")) Is Nothing Then
Range("B18:T18").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B19:T19")) Is Nothing Then
Range("B19:T19").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B20:T20")) Is Nothing Then
Range("B20:T20").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B21:T21")) Is Nothing Then
Range("B21:T21").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B22:T22")) Is Nothing Then
Range("B22:T22").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B23:T23")) Is Nothing Then
Range("B23:T23").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B24:T24")) Is Nothing Then
Range("B24:T24").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B25:T25")) Is Nothing Then
Range("B25:T25").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B26:T26")) Is Nothing Then
Range("B26:T26").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B27:T27")) Is Nothing Then
Range("B27:T27").Font.FontStyle = "Bold"
End If
If Not Intersect(Target, Range("B28:T28")) Is Nothing Then
Range("B28:T28").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B29:T29")) Is Nothing Then
Range("B29:T29").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B30:T30")) Is Nothing Then
Range("B30:T30").Font.Color = 255
End If

If Not Intersect(Target, Range("B31:T31")) Is Nothing Then
Range("B31:T31").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B32:T32")) Is Nothing Then
Range("B32:T32").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B33:T33")) Is Nothing Then
Range("B33:T33").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B34:T34")) Is Nothing Then
Range("B34:T34").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B35:T35")) Is Nothing Then
Range("B35:T35").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B36:T36")) Is Nothing Then
Range("B36:T36").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B37:T37")) Is Nothing Then
Range("B37:T37").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B38:T38")) Is Nothing Then
Range("B38:T38").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B39:T39")) Is Nothing Then
Range("B39:T39").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B40:T40")) Is Nothing Then
Range("B40:T40").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B41:T41")) Is Nothing Then
Range("B41:T41").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B42:T42")) Is Nothing Then
Range("B42:T42").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B43:T43")) Is Nothing Then
Range("B43:T43").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B44:T44")) Is Nothing Then
Range("B44:T44").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B45:T45")) Is Nothing Then
Range("B45:T45").Font.FontStyle = "Bold"
End If

If Not Intersect(Target, Range("B46:T46")) Is Nothing Then
Range("B46:T46").Font.FontStyle = "Bold"
End If

End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Try:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Range("B11:T46").Font.FontStyle = "Regular"

If Not Intersect(Target, Range("B11:T46")) Is Nothing Then
Range("B" & Target.Row & ":T" & Target.Row).Font.FontStyle = "Bold"
End If
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top