• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

Excel Macros - Help with navigation

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
brothertruffle880
Asked:
brothertruffle880
  • 2
2 Solutions
 
rspahitzCommented:
Add this to the end:

Range("A1").select
0
 
rspahitzCommented:
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
 
ChuckDeezelCommented:
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
 
FernandoFernandesCommented:
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

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now