Force cursor to go to specific cell in other worksheet

bptaw

Board Regular
Joined
Feb 27, 2017
Messages
69
Office Version
  1. 2016
Platform
  1. Windows
The following code is part of 3 cases to hide/ reveal rows and columns:
Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Activate
If Not Application.Intersect(Range("C2"), Range(Target.Address)) Is Nothing Then
Select Case Target.Value
Case Is = "Fibre": Rows("61:67").EntireRow.Hidden = True
Rows("87:92").EntireRow.Hidden = True
Rows("79:86").EntireRow.Hidden = False
Rows("68:76").EntireRow.Hidden = False

ActiveSheet.Shapes("Picture 43").Visible = False
ActiveSheet.Shapes("Picture 40").Visible = True
ActiveSheet.Shapes("Picture 39").Visible = True

With Worksheets("Summary Page")
.Range("H:V").EntireColumn.Hidden = True
.Range("A:G").EntireColumn.Hidden = False

End With


I want to force the cursor to go to a specific cell when I open the Summary Page and the case is "Fibre".
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
You said:
"I want to force the cursor to go to a specific cell."

I do not believe this is possible.
You can have a script select a certain cell or goto a particular cell.
But this does not cause the cursor to move.
 
Upvote 0
I think that is what I mean, to select a particular cell, namely the left misr unlocked cell. At the moment depending on the case the sheet might open showing just grey and I need to scroll left to see the visible cells.
 
Upvote 0
To go to A1, for example ...
VBA Code:
    Application.Goto Range("A1")
 
Upvote 0
You said:
"I want to force the cursor to go to a specific cell."

I do not believe this is possible.
You can have a script select a certain cell or goto a particular cell.
But this does not cause the cursor to move.

I'm pretty sure the cursor could be relocated, I would have to think about it a bit, but I am pretty sure the actual cursor could be relocated to a different cell.
 
Upvote 0
I ended up finding the following code which solved the issue:
Private Sub Worksheet_Activate()
Dim ws As Worksheet
Dim rng As Range

Set ws = ThisWorkbook.Sheets("Summary Page") ' Change "Sheet1" to the name of your worksheet

' Call the function to find the first unlocked and visible cell
Set rng = FindFirstUnlockedVisibleCell(ws)

' Select the first unlocked and visible cell
If Not rng Is Nothing Then
rng.Select
End If
End Sub

Function FindFirstUnlockedVisibleCell(ws As Worksheet) As Range
Dim cell As Range

' Loop through each cell in the worksheet
For Each cell In ws.UsedRange
' Check if the cell is not locked (i.e., it can be edited) and visible
If Not cell.Locked And cell.EntireRow.Hidden = False And cell.EntireColumn.Hidden = False Then
' Return the first unlocked and visible cell found
Set FindFirstUnlockedVisibleCell = cell
Exit Function
End If
Next cell

' If no unlocked and visible cell is found, return Nothing
Set FindFirstUnlockedVisibleCell = Nothing
End Function
 
Upvote 0
Solution
Glad to see you have something that works for you. I did not attempt to use this code or understand it all. But I did not see anything that would move the cursor. But maybe it does.
 
Upvote 0
It selects the first unlocked cell in the visible section of the sheet. Just what I needed.
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top