Good afternoon chaps,
I have an excell workbook which I'm trying to apply 2 events codes under the same object so I found some help and came up with this:
But I'm getting an error on the second macro Run-time error '424':
Object required
it seems the problem is on this line
I've tried to come up with something to make it work but so far I've failed
FYI The codes work perfectly by separate.
I have an excell workbook which I'm trying to apply 2 events codes under the same object so I found some help and came up with this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Call Macro1(Target)
Call Macro2(Target)
End Sub
Sub Macro1(ByVal Target As Range)
Application.EnableEvents = False
If Not Target.Cells.Count = 1 Or Target.Row = 1 Then Exit Sub
If Target.Offset(1, 0) = "" Then
Target.Offset(-1, 0).Copy
Target.PasteSpecial Paste:=xlPasteFormats
Application.CutCopyMode = False
End If
Application.EnableEvents = True
End Sub
Sub Macro2(ByVal Target As Range)
Application.ScreenUpdating = False
For Each Value In Target.Columns
Columns(Value.Column).ColumnWidth = 8.43
Worksheets(Sh.Name).Columns(Value.Column).AutoFit
Next Value
Application.ScreenUpdating = True
End Sub
But I'm getting an error on the second macro Run-time error '424':
Object required
it seems the problem is on this line
Code:
Worksheets(Sh.Name).Columns(Value.Column).AutoFit
I've tried to come up with something to make it work but so far I've failed
FYI The codes work perfectly by separate.