help with editing macro

Jagat Pavasia

Active Member
Joined
Mar 9, 2015
Messages
412
Office Version
  1. 2021
Platform
  1. Windows
hi sir,
I have Macro below, it is working as it should.
but now I want currant date and time instead of only date.

please edit and give me, I am new in Macro.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Rng As Range
 
  If Target.Count > 1 Then Exit Sub
  Application.EnableEvents = False
  ActiveSheet.Unprotect
  Set Rng = Range("b:b,g:g,i:i,k:k,m:m")
  If Not Intersect(Target, Rng) Is Nothing Then
    If Target.Value = "**" Then Target.Value = Format(Now, "MM/DD/YYYY")
    End If

  If Not Intersect(Target, Range("a2:n2")) Is Nothing Then
      If Target.Value = "" Then
          ActiveSheet.Range("a4:n4").AutoFilter Field:=Target.Column
      Else
          ActiveSheet.Range("a4:n4").AutoFilter Field:=Target.Column, Operator:=xlFilterValues, Criteria1:=CStr(Target.Value)
      End If
  End If
  ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
        False, AllowFormattingCells:=True, AllowFiltering:=True
  Application.EnableEvents = True
End Sub
 
Try changing this line in the code
Rich (BB code):
If Target.Value = "**" Then Target.Value = Format(Now, "MM/DD/YYYY hh:mm")
 
Upvote 0
Solution

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
Back
Top