chriscorpion786
New Member
Hi All,
I made a macro file with a worksheet selection change events, whenever i send it to my colleagues over the internet by mail, when they open it, they have to enable editing, after enabling editing it throws this run time error '91' object variable or with block variable not set , once you click END, the file works properly.
Is there any workaround to remove this error although I dont think my code is causing the error.
Below is my code:
>>> use code - tags <<<
I made a macro file with a worksheet selection change events, whenever i send it to my colleagues over the internet by mail, when they open it, they have to enable editing, after enabling editing it throws this run time error '91' object variable or with block variable not set , once you click END, the file works properly.
Is there any workaround to remove this error although I dont think my code is causing the error.
Below is my code:
>>> use code - tags <<<
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.DisplayAlerts = False
'this macro looksup the date and returns the tasks of that date
Dim rng As Range
Dim VL As String
Dim defaultdate As Date
Dim startdt As Date
Dim enddt As Date
Set rng = ThisWorkbook.Sheets("CALENDAR").Range("Days")
ActiveSheet.Unprotect Password:="VBA"
If Not Target.Cells.Count > 1 And Not Application.Intersect(rng, Target) Is Nothing Then
VL = Application.WorksheetFunction.VLookup(Target, ThisWorkbook.Sheets("Controls").Range("Lookupdates"), 6, False)
ThisWorkbook.Sheets("CALENDAR").Shapes("Taskforce").TextFrame2.TextRange.Text = VL
Else
ThisWorkbook.Sheets("CALENDAR").Shapes("Taskforce").TextFrame2.TextRange.Text = ""
End If
ActiveSheet.Protect Password:="VBA"
Application.DisplayAlerts = True
End Sub
Last edited by a moderator: