dannyok90
Board Regular
- Joined
- Aug 30, 2016
- Messages
- 115
Hi all
Can anybody help me merge this code correctly?
im getting a complie error block if without end if?
im new to vba and im sort of trying my hardest to understand it, i can usually snip bits of code together that i find but im struggling!
I would also like to incorporate this bit into it too but its not essential :D
Thanks
Can anybody help me merge this code correctly?
im getting a complie error block if without end if?
im new to vba and im sort of trying my hardest to understand it, i can usually snip bits of code together that i find but im struggling!
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim LastCol As Integer
With ActiveSheet
If (Target.Value = "Double click to add new") Then
Target.Worksheet.Unprotect ("TG1")
Target.Offset(, -1).EntireColumn.Copy
Cells(1, Columns.Count).End(xlToLeft).Offset(, -1).Insert
Cells(1, Columns.Count).End(xlToLeft).Offset(, -2).EntireColumn.Hidden = False
Target.Worksheet.Protect ("TG1")
Cancel = True
If (Target.Value = "Double click to add new row") Then
Target.Worksheet.Unprotect ("TG1")
Target.Offset(-1, 0).EntireRow.Copy
Target.Worksheet.Range("A" & Target.Worksheet.Cells(Target.Worksheet.Rows.Count, "B").End(xlUp).Row - 1).Insert
Target.Worksheet.Range("A" & Target.Worksheet.Cells(Target.Worksheet.Rows.Count, "B").End(xlUp).Row - 2).EntireRow.Hidden = False
Target.Worksheet.Protect ("TG1")
Cancel = True
End If
End Sub
I would also like to incorporate this bit into it too but its not essential :D
Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Column < 14 Then Exit Sub
If Target.Column > 24 Then Exit Sub
On Error GoTo ErrHandler
Application.EnableEvents = False
Target.Formula = UCase(Target.Formula)
ErrHandler:
Application.EnableEvents = True
End Sub