mkvarious
New Member
- Joined
- Jan 24, 2013
- Messages
- 44
Hello,
I have a problem that I though I overcame but seems it is not the case.
The original problem originated there:
http://www.mrexcel.com/forum/excel-questions/681429-how-get-worksheet_selection-change-work.html
Thanks to the above thread I adjusted my macro:
I thought it was working but then I realized that Change event works pretty different based on what button user presses and not which cell it has originated from. see a link w JPG below to see what my point is:
https://docs.google.com/presentation/d/1z_77av56RlXYD7lCw9u3mddamSCwMrMzejuGNdmuOR0/edit
if we start from cell H18, then based on which button we press then Excel says what is changed cell address.
So out of 8 event only 2 are related directly to the same original cell. then additional 3 events are related to the same row which is in the end not that bad for me as I may use row counter to populate formula in I column.
But my real problem is how to deal with 3 remaining events that show cell address in a different row comparing to what I originated from?
If users enters date, then presses: up arrow, down arrow or what's more likely enter then my formula will be written in incorrect row!
Can you kindly advice:
Please share some knowledge.
Thank you in advance.
mkvarious
I have a problem that I though I overcame but seems it is not the case.
The original problem originated there:
http://www.mrexcel.com/forum/excel-questions/681429-how-get-worksheet_selection-change-work.html
Thanks to the above thread I adjusted my macro:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim który As Long
Set rng = Columns(8)
If Intersect(Target, rng) Is Nothing Then Exit Sub
który = ActiveCell.Row
Cells(który, 8).Offset(0, 1).Formula = "=weeknum(" & Cells(który, 8).Address & ",2)"
End Sub
I thought it was working but then I realized that Change event works pretty different based on what button user presses and not which cell it has originated from. see a link w JPG below to see what my point is:
https://docs.google.com/presentation/d/1z_77av56RlXYD7lCw9u3mddamSCwMrMzejuGNdmuOR0/edit
if we start from cell H18, then based on which button we press then Excel says what is changed cell address.
- when ctrl + enter is pressed then it shows the same address as the cell we originated from: H18
- when delete is pressed then it shows the same address as the cell we originated from: H18
- when tab is pressed then it shows different address to that we originated from: I18
- when right arrow is pressed then it shows different address to that we originated from: I18
- when left arrow is pressed then it shows different address to that we originated from: G18
- when up arrow is pressed then it shows different address to that we originated from: H17
- when down arrow is pressed then it shows different address to that we originated from: H19
- when enter is pressed then it shows different address to that we originated from: H19
So out of 8 event only 2 are related directly to the same original cell. then additional 3 events are related to the same row which is in the end not that bad for me as I may use row counter to populate formula in I column.
But my real problem is how to deal with 3 remaining events that show cell address in a different row comparing to what I originated from?
If users enters date, then presses: up arrow, down arrow or what's more likely enter then my formula will be written in incorrect row!
Can you kindly advice:
- For my file I need to address the problem with the last 3 events: up arrow, down arrow and enter. How can I keep the original row of the cell I was changing, so in the described example row 18???
- For my future knowledge, if I ever need to capture the exact address of the cell I originated from REGARDLESS of what button is being pressed, how do I do that?
Please share some knowledge.
Thank you in advance.
mkvarious