Ambiguous name detected: Worksheet_Change

irlgh

New Member
Joined
Apr 27, 2019
Messages
2
Below is my macros when i updated on my excel i get this error msg:

<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Helvetica Neue'; color: #000000 ; color: rgba(0, 0, 0, 0.85)}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Helvetica Neue'; color: #000000 ; color: rgba(0, 0, 0, 0.85); min-height: 12.0px}</style>Compile error:


Ambiguous name detected: Worksheet_Change

--------------------------------------------------


Private Sub Worksheet_Change(ByVal Target As Range)


ThisWorkbook.RefreshAll




End Sub


Private Sub Worksheet_Change(ByVal Target As Range)


Dim myTableRange As Range
Dim myDateTimeRange As Range
Dim myUpdatedRange As Range


'Your data table range
Set myTableRange = Range("A1:R50000")


If Intersect(Target, myTableRange) Is Nothing Then Exit Sub


'Column for the date/time
Set myDateTimeRange = Range("S" & Target.Row)
'Column for the last updated date/time
Set myDateTimeRange = Range("T" & Target.Row)


If myDateTimeRange.Value = "" Then


myDateTimeRange.Value = Now

End If

myDateTimeRange.Value = Now


End Sub
 

Some videos you may like

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,770
Office Version
  1. 2010
Platform
  1. Windows
You can only have one procedure by a given name in the same module. Combine the two codes into one procedure.
 

irlgh

New Member
Joined
Apr 27, 2019
Messages
2
can u please guide me how to combine two codes into one procedure?
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,770
Office Version
  1. 2010
Platform
  1. Windows
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  ThisWorkbook.RefreshAll
  
  If Not Intersect(Target, Range("A1:R50000")) Is Nothing Then
    Cells(Target.Row, "T").Value = Now()
  End If
End Sub
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,770
Office Version
  1. 2010
Platform
  1. Windows
A little more rigorous:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim rInt As Range

  ThisWorkbook.RefreshAll

  Set rInt = Intersect(Target, Range("A1:R50000"))
  If Not rInt Is Nothing Then
    Intersect(rInt.EntireRow, Columns("T")).Value = Now()
  End If
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,114,523
Messages
5,548,547
Members
410,848
Latest member
anuradhagrewal
Top