Solved

Excel Macros - Help with navigation

Posted on 2011-02-16
4
232 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
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 …
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

759 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

20 Experts available now in Live!

Get 1:1 Help Now