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
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
You can only have one procedure by a given name in the same module. Combine the two codes into one procedure.
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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