Advice for adding line of code to existing code please

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Hi,

I am using the code below which works fine.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)  Dim c As Range
  On Error GoTo AllowEvents
  If Target.Count > 1000 Then Exit Sub
  If Not Intersect(Target, Range("B:B")) Is Nothing Then
    For Each c In Target
      If c.Row > 5 And c.Column = 2 Then
          If Len(c.Value) <> 17 And Len(c.Value) > 0 Then
          Application.EnableEvents = False
          MsgBox "VIN MUST BE 17 CHARACTERS", vbCritical, "VIN CHARACTER COUNT MESSAGE"
          c.Value = ""
          c.Select
        End If
      End If
    Next
  End If
AllowEvents:
  Application.EnableEvents = True


End Sub


What i am having an issue with now is trying to add something like the below into the code above.

Code:
Range("B").Characters(Start:=10, Length:=1).Font.ColorIndex = 3

The code needs to work for any cell in column B so when a value is typed into the cell the 10th character will be shown in a Red font colour.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi,
I understand the Worksheet_Change but i found my issue,see below.

Code:
Private Sub Worksheet_Activate()    Range("A6").Select
    Range("A4:H4").Font.Size = 24
    Range("A6:H40").Font.Size = 18
    Range("A4:H40").Font.Bold = True
    Range("A1:H4").Font.ColorIndex = 1
    Range("A4:H40").Borders.LineStyle = xlContinuous
    Range("A4:H40").HorizontalAlignment = xlCenter
    Range("A4:H40").VerticalAlignment = xlCenter
    Range("A4:H40").Name = "Calibri"
    Range("A4:H5").RowHeight = 36
    Range("A6:H40").RowHeight = 30
    [COLOR=#ff0000]Range("A6:H40").FontColorIndex = 1[/COLOR]
End Sub

Sorry for wasting your time
 
Upvote 0

Forum statistics

Threads
1,214,861
Messages
6,121,973
Members
449,059
Latest member
oculus

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