Solved

Excel: select cell without scrolling

Posted on 2012-04-12
7
321 Views
Last Modified: 2012-04-13
What Vba would I use to select a cell on a worksheet without scrolling the screen

E.g., I have the following code: activesheet.cells(1,1).select. If I am on row 2000 running this code would skip my screen to the top. What vba would i need tod select cell "A1" without skipping to the top?
0
Comment
Question by:ouestque
7 Comments
 
LVL 6

Expert Comment

by:wshark83
Comment Utility
activesheet.range("A1").select
0
 

Author Comment

by:ouestque
Comment Utility
Thank you whark, nonetheless If I move to row 10000 and run that code in the immediate window, the screen will skip to the top. I would like my screen to stay focused on row 10000 even though code selected cell "a1".
0
 
LVL 24

Expert Comment

by:StephenJR
Comment Utility
You almost certainly don't need to select the cell and then you won't have the problem. What are you trying to do?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 8

Accepted Solution

by:
ragnarok89 earned 167 total points
Comment Utility
application.screenupdating = false
range("A1").select

Alex
0
 
LVL 50

Assisted Solution

by:teylyn
teylyn earned 166 total points
Comment Utility
Hello,

If you use Select, regardless of whether you use activesheet.cells(1,1).select or activesheet.range("A1").select ( as suggested above),  the cell will be highlighted and the selection will shift to that cell.

In many cases, you don't need to actually "select" the cell to manipulate it.

"Select" is not required.

What do you want to do with the cell? It can be done without selecting it.

To change the font color, for example, you could use Select like

    Range("A1").Select
    With Selection.Font
        .Color = -16776961
        .TintAndShade = 0
    End With

Open in new window


But you can change the font color without selecting if you use

    With Range("A1").Font
        .Color = -16776961
        .TintAndShade = 0
    End With

Open in new window


The same outcome, but without selecting and shifting the focus of the sheet.

cheers, teylyn
0
 
LVL 43

Assisted Solution

by:Saqib Husain, Syed
Saqib Husain, Syed earned 167 total points
Comment Utility
Maybe this will work

Sub a()
Dim sr As Long, sc As Long
sr = ActiveWindow.ScrollRow
sc = ActiveWindow.ScrollColumn
Range("A1").Select
ActiveWindow.ScrollRow = sr
ActiveWindow.ScrollColumn = sc
End Sub
0
 
LVL 24

Expert Comment

by:StephenJR
Comment Utility
ssaqibh - very neat.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now