Solved

Excel Macros - Help with navigation

Posted on 2011-02-16
4
236 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
  • 2
4 Comments
 
LVL 22

Accepted Solution

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

Range("A1").select
0
 
LVL 22

Assisted Solution

by:rspahitz
rspahitz earned 500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

820 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