Incorporating functions in a change object sheet

EinarOSies

New Member
Joined
Feb 15, 2021
Messages
41
Office Version
  1. 2019
Platform
  1. Windows
I am trying to incorporate some function codes into a sheet change procedure module. The function are





VBA Code:
Function LastSaveDate() As Date

LastSaveDate = ActiveWorkbook.BuiltinDocumentProperties("Last Save Time")

End Function



Function LastSavedBy()

LastSavedBy = ThisWorkbook.BuiltinDocumentProperties("Last Author")

End Function



Function ExcelAuthor()

Excel Author = ThisWorkbook.BuiltinDocumentProperties("Author")

End Function



Function ExcelFileSize()

ExcelFileSize = FileLen(ThisWorkbook.FullName)

End Function



And the change procedure  code is

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("C3:O39")) Is Nothing Then
On Error Resume Next

If Target.Value = "" Then
Range("C3:O39").Value = ""

Else

Range("M6").Value = LastSaveDate

End If

End If

If Not Intersect(Target, Range("C3:O39")) Is Nothing Then
On Error Resume Next

If Target.Value = "" Then
Range("C3:O39").Value = ""

Else

Range("N7").Value = LastSavedBy

End If

End If

If Not Intersect(Target, Range("C3:O39")) Is Nothing Then
On Error Resume Next

If Target.Value = "" Then
Range("C3:O39").Value = ""

Else

Range("I7").Value = ExcelFileSize

End If

End If
End Sub
When I make a change in the sheet it closes excel.
Please I don't know what is wrong with my code, please any help!!!
 
Last edited by a moderator:

Some videos you may like

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,574
Office Version
  1. 365
Platform
  1. Windows
Hi & welcome to MrExcel.
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Not Intersect(Target, Range("C3:O39")) Is Nothing Then
      If Target.Value = "" Then
         Range("C3:O39") = ""
      Else
         On Error GoTo Xit
         Application.EnableEvents = False
         Range("M6").Value = LastSaveDate
         Range("N7").Value = LastSavedBy
         Range("I7").Value = ExcelFileSize
         Application.EnableEvents = True
      End If
   End If
Xit:
   Application.EnableEvents = True
End Sub
 

EinarOSies

New Member
Joined
Feb 15, 2021
Messages
41
Office Version
  1. 2019
Platform
  1. Windows
Hi & welcome to MrExcel.
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Not Intersect(Target, Range("C3:O39")) Is Nothing Then
      If Target.Value = "" Then
         Range("C3:O39") = ""
      Else
         On Error GoTo Xit
         Application.EnableEvents = False
         Range("M6").Value = LastSaveDate
         Range("N7").Value = LastSavedBy
         Range("I7").Value = ExcelFileSize
         Application.EnableEvents = True
      End If
   End If
Xit:
   Application.EnableEvents = True
End Sub
Mmm it still closes
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,574
Office Version
  1. 365
Platform
  1. Windows
Did you delete your existing change event & paste my code in?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,574
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,632
Messages
5,625,990
Members
416,149
Latest member
Bigpotato 668

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
Top