Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-05-2023, 03:34 AM
soroush.kalantari soroush.kalantari is offline How to go to Nth precedents of active cell? Windows 10 How to go to Nth precedents of active cell? Office 2016
Competent Performer
How to go to Nth precedents of active cell?
 
Join Date: Jun 2021
Posts: 115
soroush.kalantari is on a distinguished road
Default 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
Attached Files
File Type: xlsm direct.precenedts.xlsm (15.7 KB, 4 views)
Reply With Quote
 

Tags
prcedent



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to go to Nth precedents of active cell? 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
How to go to Nth precedents of active cell? 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
How to go to Nth precedents of active cell? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 05:20 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft