Hi everyone!
I have a following problem. I have an Excel sheet, which uses a auto web query feature and it supposed to update cell J17 value. The query works well but the problem is that I want to add to column A, in the next empty cell, the updated value, from cell J17, by the web query. Well, it works well, if I update the cell J17 manually, but it won't work if update is done by web query. In addition, my code adds a date and time to columns B and C if colunm A has a data.
I created a code below:
Private Sub Cell_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A2 :A60000")) Is Nothing Then
With Target(1, 2)
.Value = Date
.EntireColumn.AutoFit
End With
With Target(1, 3)
.Value = Now
.EntireColumn.AutoFit
End With
End If
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Address = "$J$17" Then
'Ensure target is a number
If IsNumeric(Target) Then
'Stop any possible runtime errors and halting code
On Error Resume Next
'Turn off ALL events so the Target does not _
put the code into a loop.
Application.EnableEvents = False
Target.Copy
'Turn events back on
Application.EnableEvents = True
Range("A65536").End(xlUp).Offset(1, 0).Select
Selection = Target
'Allow run time errors again
On Error GoTo 0
End If
End If
End Sub
-JK
I have a following problem. I have an Excel sheet, which uses a auto web query feature and it supposed to update cell J17 value. The query works well but the problem is that I want to add to column A, in the next empty cell, the updated value, from cell J17, by the web query. Well, it works well, if I update the cell J17 manually, but it won't work if update is done by web query. In addition, my code adds a date and time to columns B and C if colunm A has a data.
I created a code below:
Private Sub Cell_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A2 :A60000")) Is Nothing Then
With Target(1, 2)
.Value = Date
.EntireColumn.AutoFit
End With
With Target(1, 3)
.Value = Now
.EntireColumn.AutoFit
End With
End If
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Address = "$J$17" Then
'Ensure target is a number
If IsNumeric(Target) Then
'Stop any possible runtime errors and halting code
On Error Resume Next
'Turn off ALL events so the Target does not _
put the code into a loop.
Application.EnableEvents = False
Target.Copy
'Turn events back on
Application.EnableEvents = True
Range("A65536").End(xlUp).Offset(1, 0).Select
Selection = Target
'Allow run time errors again
On Error GoTo 0
End If
End If
End Sub
-JK