?
Solved

Excel Macros - Help with navigation

Posted on 2011-02-16
4
Medium Priority
?
239 Views
Last Modified: 2012-05-11
I have a macro that bolds a cell and changes the size of the font.  However, I would like the macro to position the cursor at cell A1 (the very top/beginning of my spreadsheet).
What command do I need to add to this macro.
Also, I didn't make any modifications to "shadow," "subscript," etc.  Can I safely delete those lines from my macro?

Sub test()
' test Macro
    Selection.Font.Bold = True
    With Selection.Font
        .Name = "Calibri"
        .Size = 22
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ThemeColor = xlThemeColorLight1
        .TintAndShade = 0
        .ThemeFont = xlThemeFontNone
    End With
End Sub
0
Comment
Question by:brothertruffle880
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
rspahitz earned 2000 total points
ID: 34908300
Add this to the end:

Range("A1").select
0
 
LVL 22

Assisted Solution

by:rspahitz
rspahitz earned 2000 total points
ID: 34908326
Oh, and yes, you can delete the other things that you don't use.  Excel likes to add things to try to make sure the cell looks exactly the same each time you run the macro, even if those things weren't changed.
0
 
LVL 4

Expert Comment

by:ChuckDeezel
ID: 34908367
Try using this function:

Public Declare Function SetCursorPosition Lib "user32" (ByVal XX As Long, ByVal YY As Long) As Long

Private Sub CommandButton1_Click()
Call SetCursorPosition(0, 0)
End Sub

Open in new window


I dont know if that will 100% work, but it looks to be promising. Also you can delete the other fields.
0
 
LVL 6

Expert Comment

by:FernandoFernandes
ID: 34908521
add these activewindow lines to the bottom of the code as well, right after (or before, doesn't matter) rspahitz's suggestion...
Range("A1").select
Activewindow.ScrollRow =1
ActiveWindow.ScrollColumn = 1

Open in new window

0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

765 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