ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,738
- Office Version
- 2007
- Platform
- Windows
Morning,
On my worksheet i use the following codes which,highlight the row that i am on,change the text to CAPITALS & also a button to insert a new row.
When i insert a new row i get a Run time error 13,type mismatch.
When i click on debug i see this line shown in yellow .Value = UCase(.Value)
Without the CAPITAL code in the sheet this above issue is gone.
Please could you advise how i get around this issue.
I also use this code to change text to CAPITALS.
There is also a new insert button.
On my worksheet i use the following codes which,highlight the row that i am on,change the text to CAPITALS & also a button to insert a new row.
When i insert a new row i get a Run time error 13,type mismatch.
When i click on debug i see this line shown in yellow .Value = UCase(.Value)
Without the CAPITAL code in the sheet this above issue is gone.
Please could you advise how i get around this issue.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim myStartCol As String
Dim myEndCol As String
Dim myStartRow As Long
Dim myLastRow As Long
Dim myRange As Range
If Target.Cells.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
' *** Specify columns to apply this to ***
myStartCol = "A"
myEndCol = "F"
' *** Specify start row ***
myStartRow = 4
' Use first column to find the last row
myLastRow = Cells(Rows.Count, myStartCol).End(xlUp).Row
' Build range to apply this to
Set myRange = Range(Cells(myStartRow, myStartCol), Cells(myLastRow, myEndCol))
' Clear the color of all the cells in range
myRange.Interior.ColorIndex = 6
' Check to see if cell selected is outside of range
If Intersect(Target, myRange) Is Nothing Then Exit Sub
' Highlight the row and column that contain the active cell
Range(Cells(Target.Row, myStartCol), Cells(Target.Row, myEndCol)).Interior.ColorIndex = 8
Target.Interior.Color = vbGreen
Application.ScreenUpdating = True
End Sub
I also use this code to change text to CAPITALS.
Code:
Private Sub Worksheet_Change(ByVal Target As Range) With Target
If Not .HasFormula Then
Application.EnableEvents = False
.Value = UCase(.Value)
Application.EnableEvents = True
End If
End With
End Sub
There is also a new insert button.
Code:
Private Sub NewRowButton_Click()Sheets("SKP IMMO LIST").Range("A4").Select
ActiveCell.EntireRow.Insert Shift:=xlDown
Sheets("SKP IMMO LIST").Range("A4:F4").Select
Selection.Borders.Weight = xlThin
Sheets("SKP IMMO LIST").Range("A4").Select
End Sub