#1
|
|||
|
|||
How to go to Nth precedents of active cell?
I have written the following code to make excel go to nth direct precedents of a cell which are in the same sheet. (As far as I know, there is no way to write a code that does this job for precedents which are out of the sheet the active cell lies.) it failes to do its expected job. (see the excel attachment, when running the code for cell E1 and entering 2 in the input box appearing after running the code, it is expected to go to cell D4 but it goes to cell c2.
Sub gotopresedence() Dim Rng As Range, RngPrecedents As Range Dim i As Long, j As Long Application.Goto Reference:=Selection Set Rng = ActiveCell Set RngPrecedents = Rng.DirectPrecedents Application.Goto Reference:=RngPrecedents(InputBox("what presedence")) End Sub |
Tags |
prcedent |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
access active cell in word vba | littlepeaks | Word VBA | 5 | 08-24-2022 09:14 PM |
Move active cell down | Marcia | Excel Programming | 2 | 06-22-2022 04:10 PM |
Change active cell after running macro in active cell via selection change | Peterson | Excel Programming | 3 | 03-07-2021 12:19 PM |
Cell equal value new value of active cell which is a drop down | hassanmoukadem | Excel Programming | 1 | 04-13-2020 07:54 PM |
Clear all cell colors within a range starting at cell A8 and change row of active cell to yellow | FUGMAN | Excel Programming | 7 | 02-05-2017 08:37 AM |