Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Feb 2009
    Location
    Kings Park, Victoria, Australia
    Posts
    90
    Thanks
    15
    Thanked 5 Times in 5 Posts

    Numlock turns off/on when macro is run

    Hi,

    I have a very small macro shown below to insert an X mark then move to the next cell. When I first created this macro the last command was as follows : Sendkeys "{TAB}". The story is this, I am using Excel 2007 in a Win 7 Virtual Desktop - whenever I ran the macro in this environment, the Numlock would turn off and if I ran it a second time Numlock turned back on - If I ran it under my normal XP desktop version of Excel 2007 - no issue. This was very annoying and I had to change the code to that shown below to stop the Numlock issue. Does anyone know why this should happen.

    Sub XMark()
    '
    ' XMark Macro
    ' Insert X in Wingdings font
    '
    '
    ActiveCell.FormulaR1C1 = ""
    With Selection.Font
    .Name = "Wingdings"
    .Size = 14
    .Strikethrough = False
    .Superscript = False
    .Subscript = False
    .OutlineFont = False
    .Shadow = False
    .Underline = xlUnderlineStyleNone
    .ThemeColor = xlThemeColorLight1
    .TintAndShade = 0
    .ThemeFont = xlThemeFontNone
    End With

    With Selection
    .HorizontalAlignment = xlCenter
    End With

    ActiveCell.Offset(0, 1).Select
    End Sub

    Regards,
    Maria
    Maria
    Simmo7
    Victoria, Australia

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    It's a known issue with SendKeys. There is some replacement code here if you need it, but there is no need for it here. The code you have is better anyway.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. The Following User Says Thank You to rory For This Useful Post:

    simmo7 (2011-09-15)

  4. #3
    Star Lounger
    Join Date
    Feb 2009
    Location
    Kings Park, Victoria, Australia
    Posts
    90
    Thanks
    15
    Thanked 5 Times in 5 Posts
    Thanks Rory, Good to know that I am not going crazy - I couldn't figure out how sendkeys {TAB}" would turn off/on Numlock. The good thing about the new code is that if I want to change the code to move down after putting the X mark, I can simply change the offset to (1,0) instead of (0,1).

    Regards,
    Maria
    Maria
    Simmo7
    Victoria, Australia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •