VBA code needed to clear contents of cell AQ when value of cell D changes; Microsoft Excel for Office 365 MSO...
up vote
0
down vote
favorite
I'll preface this by saying that programming is not my strong suit but I would appreciate any help.
I have used the below formula in an attempt to clear the contents of cell AQ when the value of cell D (on the same row) changes. Currently, the contents are only cleared in AQ when the value in cell D changes to 1 (presumably due to the line "If Target = 1 Then". What do I use instead of "1" so that all changes, from any value to any value, will initiate the ClearContents instruction for cell AQ?
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
If Target = 1 Then
Range("AQ" & Target.Row).ClearContents
End If
End If
End Sub
microsoft-excel vba microsoft-excel-2016
add a comment |
up vote
0
down vote
favorite
I'll preface this by saying that programming is not my strong suit but I would appreciate any help.
I have used the below formula in an attempt to clear the contents of cell AQ when the value of cell D (on the same row) changes. Currently, the contents are only cleared in AQ when the value in cell D changes to 1 (presumably due to the line "If Target = 1 Then". What do I use instead of "1" so that all changes, from any value to any value, will initiate the ClearContents instruction for cell AQ?
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
If Target = 1 Then
Range("AQ" & Target.Row).ClearContents
End If
End If
End Sub
microsoft-excel vba microsoft-excel-2016
Why are you testingIf Target = 1
? Why not just take it out and doIf Not Intersect(Target, Range("D7:D506")) Is Nothing Then
...Range("AQ" & Target.Row).ClearContents
?
– Scott
Nov 20 at 2:53
Hi Scott, I just figured this out. I should've looked at your response an hour ago! To answer your question: that's the problem when one plagiarises all one's code from other similar examples on the web. Simple solutions are not obvious to the uninitiated. While I have you, is there code i could add that would prevent AQ from clearing if the value of D is changed to the same value. (i.e. D=1, then i input D=1 again). Currently the code can't differentiate between a true change in value (i.e. 1 to 2) and just a re-entering of the same value (i.e. 1 to 1).
– MJS
Nov 20 at 4:09
Interesting question. I have fairly little experience withWorksheet_Change
. I assume that you’ve verified through experimentation that theWorksheet_Change
routine gets called even when a cell is “changed” to its current value? In that case, I suspect that you’re out of luck (anybody who knows better, feel free to correct me!). The one thing I can suggest is that you keep a backup copy of ColumnD
, and compare the “new” value to your saved copy.
– Scott
Nov 20 at 4:17
Thanks for the help @Scott
– MJS
Nov 20 at 23:15
Thank you @Christofer Weber. I had some issues with your code but I received a (seemingly) workable solution on another forum in the meantime so hopefully won't need this now. But thank you for your time and effort.
– MJS
Nov 21 at 10:47
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'll preface this by saying that programming is not my strong suit but I would appreciate any help.
I have used the below formula in an attempt to clear the contents of cell AQ when the value of cell D (on the same row) changes. Currently, the contents are only cleared in AQ when the value in cell D changes to 1 (presumably due to the line "If Target = 1 Then". What do I use instead of "1" so that all changes, from any value to any value, will initiate the ClearContents instruction for cell AQ?
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
If Target = 1 Then
Range("AQ" & Target.Row).ClearContents
End If
End If
End Sub
microsoft-excel vba microsoft-excel-2016
I'll preface this by saying that programming is not my strong suit but I would appreciate any help.
I have used the below formula in an attempt to clear the contents of cell AQ when the value of cell D (on the same row) changes. Currently, the contents are only cleared in AQ when the value in cell D changes to 1 (presumably due to the line "If Target = 1 Then". What do I use instead of "1" so that all changes, from any value to any value, will initiate the ClearContents instruction for cell AQ?
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
If Target = 1 Then
Range("AQ" & Target.Row).ClearContents
End If
End If
End Sub
microsoft-excel vba microsoft-excel-2016
microsoft-excel vba microsoft-excel-2016
asked Nov 20 at 1:45
MJS
11
11
Why are you testingIf Target = 1
? Why not just take it out and doIf Not Intersect(Target, Range("D7:D506")) Is Nothing Then
...Range("AQ" & Target.Row).ClearContents
?
– Scott
Nov 20 at 2:53
Hi Scott, I just figured this out. I should've looked at your response an hour ago! To answer your question: that's the problem when one plagiarises all one's code from other similar examples on the web. Simple solutions are not obvious to the uninitiated. While I have you, is there code i could add that would prevent AQ from clearing if the value of D is changed to the same value. (i.e. D=1, then i input D=1 again). Currently the code can't differentiate between a true change in value (i.e. 1 to 2) and just a re-entering of the same value (i.e. 1 to 1).
– MJS
Nov 20 at 4:09
Interesting question. I have fairly little experience withWorksheet_Change
. I assume that you’ve verified through experimentation that theWorksheet_Change
routine gets called even when a cell is “changed” to its current value? In that case, I suspect that you’re out of luck (anybody who knows better, feel free to correct me!). The one thing I can suggest is that you keep a backup copy of ColumnD
, and compare the “new” value to your saved copy.
– Scott
Nov 20 at 4:17
Thanks for the help @Scott
– MJS
Nov 20 at 23:15
Thank you @Christofer Weber. I had some issues with your code but I received a (seemingly) workable solution on another forum in the meantime so hopefully won't need this now. But thank you for your time and effort.
– MJS
Nov 21 at 10:47
add a comment |
Why are you testingIf Target = 1
? Why not just take it out and doIf Not Intersect(Target, Range("D7:D506")) Is Nothing Then
...Range("AQ" & Target.Row).ClearContents
?
– Scott
Nov 20 at 2:53
Hi Scott, I just figured this out. I should've looked at your response an hour ago! To answer your question: that's the problem when one plagiarises all one's code from other similar examples on the web. Simple solutions are not obvious to the uninitiated. While I have you, is there code i could add that would prevent AQ from clearing if the value of D is changed to the same value. (i.e. D=1, then i input D=1 again). Currently the code can't differentiate between a true change in value (i.e. 1 to 2) and just a re-entering of the same value (i.e. 1 to 1).
– MJS
Nov 20 at 4:09
Interesting question. I have fairly little experience withWorksheet_Change
. I assume that you’ve verified through experimentation that theWorksheet_Change
routine gets called even when a cell is “changed” to its current value? In that case, I suspect that you’re out of luck (anybody who knows better, feel free to correct me!). The one thing I can suggest is that you keep a backup copy of ColumnD
, and compare the “new” value to your saved copy.
– Scott
Nov 20 at 4:17
Thanks for the help @Scott
– MJS
Nov 20 at 23:15
Thank you @Christofer Weber. I had some issues with your code but I received a (seemingly) workable solution on another forum in the meantime so hopefully won't need this now. But thank you for your time and effort.
– MJS
Nov 21 at 10:47
Why are you testing
If Target = 1
? Why not just take it out and do If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
... Range("AQ" & Target.Row).ClearContents
?– Scott
Nov 20 at 2:53
Why are you testing
If Target = 1
? Why not just take it out and do If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
... Range("AQ" & Target.Row).ClearContents
?– Scott
Nov 20 at 2:53
Hi Scott, I just figured this out. I should've looked at your response an hour ago! To answer your question: that's the problem when one plagiarises all one's code from other similar examples on the web. Simple solutions are not obvious to the uninitiated. While I have you, is there code i could add that would prevent AQ from clearing if the value of D is changed to the same value. (i.e. D=1, then i input D=1 again). Currently the code can't differentiate between a true change in value (i.e. 1 to 2) and just a re-entering of the same value (i.e. 1 to 1).
– MJS
Nov 20 at 4:09
Hi Scott, I just figured this out. I should've looked at your response an hour ago! To answer your question: that's the problem when one plagiarises all one's code from other similar examples on the web. Simple solutions are not obvious to the uninitiated. While I have you, is there code i could add that would prevent AQ from clearing if the value of D is changed to the same value. (i.e. D=1, then i input D=1 again). Currently the code can't differentiate between a true change in value (i.e. 1 to 2) and just a re-entering of the same value (i.e. 1 to 1).
– MJS
Nov 20 at 4:09
Interesting question. I have fairly little experience with
Worksheet_Change
. I assume that you’ve verified through experimentation that the Worksheet_Change
routine gets called even when a cell is “changed” to its current value? In that case, I suspect that you’re out of luck (anybody who knows better, feel free to correct me!). The one thing I can suggest is that you keep a backup copy of Column D
, and compare the “new” value to your saved copy.– Scott
Nov 20 at 4:17
Interesting question. I have fairly little experience with
Worksheet_Change
. I assume that you’ve verified through experimentation that the Worksheet_Change
routine gets called even when a cell is “changed” to its current value? In that case, I suspect that you’re out of luck (anybody who knows better, feel free to correct me!). The one thing I can suggest is that you keep a backup copy of Column D
, and compare the “new” value to your saved copy.– Scott
Nov 20 at 4:17
Thanks for the help @Scott
– MJS
Nov 20 at 23:15
Thanks for the help @Scott
– MJS
Nov 20 at 23:15
Thank you @Christofer Weber. I had some issues with your code but I received a (seemingly) workable solution on another forum in the meantime so hopefully won't need this now. But thank you for your time and effort.
– MJS
Nov 21 at 10:47
Thank you @Christofer Weber. I had some issues with your code but I received a (seemingly) workable solution on another forum in the meantime so hopefully won't need this now. But thank you for your time and effort.
– MJS
Nov 21 at 10:47
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
To make sure a true change has occurred, we first save the value of the selected cell as a public variable. Since you can select more than one cell at once, I've decided to use a public Collection.
Then when a change occurs we compare the new value of that cell to the old value in the collection, and only if they don't match, clear the contents of AQ.
Something like:
Public coll As New Collection
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cel As Range
Set coll = New Collection
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
For Each cel In Target
coll.Add cel.Value, cel.Address
Next cel
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
If Not Target.Value = coll(Target.Address) Then
Range("AQ" & Target.Row).ClearContents
End If
End If
End Sub
Edit updated to work when selecting multiple cells.
Obviously, if you change a value in Range("D7:D506")
without actually selecting the cell first, this code will throw an error.
Come to think of it, you can edit multiple cells at once, if you delete the value. Then this code will also throw an error.
But we can work around that by using the same approach in Worksheet_Change
as we are doing in Worksheet_SelectionChange
:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cel As Range
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
For Each cel In Target
If Not cel.Value = coll(cel.Address) Then
Range("AQ" & cel.Row).ClearContents
End If
Next cel
End If
End Sub
1
(1) Nice. I was thinking in terms of keeping a copy of ColumnD
somewhere else on the worksheet (e.g., ColumnAD
); keeping it in VBA memory seems safer. (2) Between the question title and theIf Not Intersect(Target, Range("D7:D506")) Is Nothing Then
line, it appears that the user is concerned only with changes in ColumnD
; specifically, in the rangeD7:D506
. So I would suggest that your routine should do, notFor Each cel In Target
, but ratherFor Each cel In Intersect(Target, Range("D7:D506"))
.
– Scott
Nov 26 at 22:24
Putting the intersect in the for loop condition? Never thought of that. I like it! Very efficient.
– Christofer Weber
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
To make sure a true change has occurred, we first save the value of the selected cell as a public variable. Since you can select more than one cell at once, I've decided to use a public Collection.
Then when a change occurs we compare the new value of that cell to the old value in the collection, and only if they don't match, clear the contents of AQ.
Something like:
Public coll As New Collection
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cel As Range
Set coll = New Collection
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
For Each cel In Target
coll.Add cel.Value, cel.Address
Next cel
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
If Not Target.Value = coll(Target.Address) Then
Range("AQ" & Target.Row).ClearContents
End If
End If
End Sub
Edit updated to work when selecting multiple cells.
Obviously, if you change a value in Range("D7:D506")
without actually selecting the cell first, this code will throw an error.
Come to think of it, you can edit multiple cells at once, if you delete the value. Then this code will also throw an error.
But we can work around that by using the same approach in Worksheet_Change
as we are doing in Worksheet_SelectionChange
:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cel As Range
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
For Each cel In Target
If Not cel.Value = coll(cel.Address) Then
Range("AQ" & cel.Row).ClearContents
End If
Next cel
End If
End Sub
1
(1) Nice. I was thinking in terms of keeping a copy of ColumnD
somewhere else on the worksheet (e.g., ColumnAD
); keeping it in VBA memory seems safer. (2) Between the question title and theIf Not Intersect(Target, Range("D7:D506")) Is Nothing Then
line, it appears that the user is concerned only with changes in ColumnD
; specifically, in the rangeD7:D506
. So I would suggest that your routine should do, notFor Each cel In Target
, but ratherFor Each cel In Intersect(Target, Range("D7:D506"))
.
– Scott
Nov 26 at 22:24
Putting the intersect in the for loop condition? Never thought of that. I like it! Very efficient.
– Christofer Weber
2 days ago
add a comment |
up vote
0
down vote
To make sure a true change has occurred, we first save the value of the selected cell as a public variable. Since you can select more than one cell at once, I've decided to use a public Collection.
Then when a change occurs we compare the new value of that cell to the old value in the collection, and only if they don't match, clear the contents of AQ.
Something like:
Public coll As New Collection
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cel As Range
Set coll = New Collection
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
For Each cel In Target
coll.Add cel.Value, cel.Address
Next cel
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
If Not Target.Value = coll(Target.Address) Then
Range("AQ" & Target.Row).ClearContents
End If
End If
End Sub
Edit updated to work when selecting multiple cells.
Obviously, if you change a value in Range("D7:D506")
without actually selecting the cell first, this code will throw an error.
Come to think of it, you can edit multiple cells at once, if you delete the value. Then this code will also throw an error.
But we can work around that by using the same approach in Worksheet_Change
as we are doing in Worksheet_SelectionChange
:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cel As Range
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
For Each cel In Target
If Not cel.Value = coll(cel.Address) Then
Range("AQ" & cel.Row).ClearContents
End If
Next cel
End If
End Sub
1
(1) Nice. I was thinking in terms of keeping a copy of ColumnD
somewhere else on the worksheet (e.g., ColumnAD
); keeping it in VBA memory seems safer. (2) Between the question title and theIf Not Intersect(Target, Range("D7:D506")) Is Nothing Then
line, it appears that the user is concerned only with changes in ColumnD
; specifically, in the rangeD7:D506
. So I would suggest that your routine should do, notFor Each cel In Target
, but ratherFor Each cel In Intersect(Target, Range("D7:D506"))
.
– Scott
Nov 26 at 22:24
Putting the intersect in the for loop condition? Never thought of that. I like it! Very efficient.
– Christofer Weber
2 days ago
add a comment |
up vote
0
down vote
up vote
0
down vote
To make sure a true change has occurred, we first save the value of the selected cell as a public variable. Since you can select more than one cell at once, I've decided to use a public Collection.
Then when a change occurs we compare the new value of that cell to the old value in the collection, and only if they don't match, clear the contents of AQ.
Something like:
Public coll As New Collection
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cel As Range
Set coll = New Collection
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
For Each cel In Target
coll.Add cel.Value, cel.Address
Next cel
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
If Not Target.Value = coll(Target.Address) Then
Range("AQ" & Target.Row).ClearContents
End If
End If
End Sub
Edit updated to work when selecting multiple cells.
Obviously, if you change a value in Range("D7:D506")
without actually selecting the cell first, this code will throw an error.
Come to think of it, you can edit multiple cells at once, if you delete the value. Then this code will also throw an error.
But we can work around that by using the same approach in Worksheet_Change
as we are doing in Worksheet_SelectionChange
:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cel As Range
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
For Each cel In Target
If Not cel.Value = coll(cel.Address) Then
Range("AQ" & cel.Row).ClearContents
End If
Next cel
End If
End Sub
To make sure a true change has occurred, we first save the value of the selected cell as a public variable. Since you can select more than one cell at once, I've decided to use a public Collection.
Then when a change occurs we compare the new value of that cell to the old value in the collection, and only if they don't match, clear the contents of AQ.
Something like:
Public coll As New Collection
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cel As Range
Set coll = New Collection
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
For Each cel In Target
coll.Add cel.Value, cel.Address
Next cel
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
If Not Target.Value = coll(Target.Address) Then
Range("AQ" & Target.Row).ClearContents
End If
End If
End Sub
Edit updated to work when selecting multiple cells.
Obviously, if you change a value in Range("D7:D506")
without actually selecting the cell first, this code will throw an error.
Come to think of it, you can edit multiple cells at once, if you delete the value. Then this code will also throw an error.
But we can work around that by using the same approach in Worksheet_Change
as we are doing in Worksheet_SelectionChange
:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cel As Range
If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
For Each cel In Target
If Not cel.Value = coll(cel.Address) Then
Range("AQ" & cel.Row).ClearContents
End If
Next cel
End If
End Sub
edited Nov 20 at 18:43
answered Nov 20 at 15:35
Christofer Weber
709413
709413
1
(1) Nice. I was thinking in terms of keeping a copy of ColumnD
somewhere else on the worksheet (e.g., ColumnAD
); keeping it in VBA memory seems safer. (2) Between the question title and theIf Not Intersect(Target, Range("D7:D506")) Is Nothing Then
line, it appears that the user is concerned only with changes in ColumnD
; specifically, in the rangeD7:D506
. So I would suggest that your routine should do, notFor Each cel In Target
, but ratherFor Each cel In Intersect(Target, Range("D7:D506"))
.
– Scott
Nov 26 at 22:24
Putting the intersect in the for loop condition? Never thought of that. I like it! Very efficient.
– Christofer Weber
2 days ago
add a comment |
1
(1) Nice. I was thinking in terms of keeping a copy of ColumnD
somewhere else on the worksheet (e.g., ColumnAD
); keeping it in VBA memory seems safer. (2) Between the question title and theIf Not Intersect(Target, Range("D7:D506")) Is Nothing Then
line, it appears that the user is concerned only with changes in ColumnD
; specifically, in the rangeD7:D506
. So I would suggest that your routine should do, notFor Each cel In Target
, but ratherFor Each cel In Intersect(Target, Range("D7:D506"))
.
– Scott
Nov 26 at 22:24
Putting the intersect in the for loop condition? Never thought of that. I like it! Very efficient.
– Christofer Weber
2 days ago
1
1
(1) Nice. I was thinking in terms of keeping a copy of Column
D
somewhere else on the worksheet (e.g., Column AD
); keeping it in VBA memory seems safer. (2) Between the question title and the If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
line, it appears that the user is concerned only with changes in Column D
; specifically, in the range D7:D506
. So I would suggest that your routine should do, not For Each cel In Target
, but rather For Each cel In Intersect(Target, Range("D7:D506"))
.– Scott
Nov 26 at 22:24
(1) Nice. I was thinking in terms of keeping a copy of Column
D
somewhere else on the worksheet (e.g., Column AD
); keeping it in VBA memory seems safer. (2) Between the question title and the If Not Intersect(Target, Range("D7:D506")) Is Nothing Then
line, it appears that the user is concerned only with changes in Column D
; specifically, in the range D7:D506
. So I would suggest that your routine should do, not For Each cel In Target
, but rather For Each cel In Intersect(Target, Range("D7:D506"))
.– Scott
Nov 26 at 22:24
Putting the intersect in the for loop condition? Never thought of that. I like it! Very efficient.
– Christofer Weber
2 days ago
Putting the intersect in the for loop condition? Never thought of that. I like it! Very efficient.
– Christofer Weber
2 days ago
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1376833%2fvba-code-needed-to-clear-contents-of-cell-aq-when-value-of-cell-d-changes-micro%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Why are you testing
If Target = 1
? Why not just take it out and doIf Not Intersect(Target, Range("D7:D506")) Is Nothing Then
...Range("AQ" & Target.Row).ClearContents
?– Scott
Nov 20 at 2:53
Hi Scott, I just figured this out. I should've looked at your response an hour ago! To answer your question: that's the problem when one plagiarises all one's code from other similar examples on the web. Simple solutions are not obvious to the uninitiated. While I have you, is there code i could add that would prevent AQ from clearing if the value of D is changed to the same value. (i.e. D=1, then i input D=1 again). Currently the code can't differentiate between a true change in value (i.e. 1 to 2) and just a re-entering of the same value (i.e. 1 to 1).
– MJS
Nov 20 at 4:09
Interesting question. I have fairly little experience with
Worksheet_Change
. I assume that you’ve verified through experimentation that theWorksheet_Change
routine gets called even when a cell is “changed” to its current value? In that case, I suspect that you’re out of luck (anybody who knows better, feel free to correct me!). The one thing I can suggest is that you keep a backup copy of ColumnD
, and compare the “new” value to your saved copy.– Scott
Nov 20 at 4:17
Thanks for the help @Scott
– MJS
Nov 20 at 23:15
Thank you @Christofer Weber. I had some issues with your code but I received a (seemingly) workable solution on another forum in the meantime so hopefully won't need this now. But thank you for your time and effort.
– MJS
Nov 21 at 10:47