Filehost.ro - gazduire fisiere
Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Nou pe simpatie:
Sophya pe Simpatie.ro
Femeie
25 ani
Bucuresti
cauta Barbat
25 - 54 ani
Mrrrr's Forum (VIEW ONLY)ReguliInregistrareLoginPozeNu sunteti logat. Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides /

[EXCEL] On Worksheet Change, Insert Date into Cell [VBA]

Pagini: 1 Moderat de TRaP, TonyTzu
#1
TRaP
Moderator
Postari: 960
The following code is pun the the Worksheet code and upon any change in range A1:L300 it will insert the current date (today) in cell F1.


Public Sub Worksheet_Change(ByVal Target As Range)

Application.ScreenUpdating = False
Application.EnableEvents = False

Dim keyCells As Range
Set keyCells = Range("A1:L300")

If Not Application.Intersect(keyCells, Range(Target.Address)) Is Nothing Then
    Worksheets("Sheet1").Range("F1").Value = Date
End If

Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub


Without using Application.ScreenUpdating and Application.EnableEvents the code would give error 2147417848 upon running, and Excel would freeze completely afterwards.

Sources:
https://docs.microsoft.com/en-us/office ... lls-change
https://www.excelforum.com/excel-progra ... reeze.html


 
   
Pagini: 1  
Mergi la