+ Reply to Thread
Results 1 to 10 of 10

Macro with Sendkeys no longer works

  1. #1
    Registered User
    Join Date
    08-08-2013
    Location
    Colorado, USA
    MS-Off Ver
    365
    Posts
    44

    Macro with Sendkeys no longer works

    I had a macro that used to work (Excel 2010). We recently upgraded to Windows 8, and it no longer works the way it's supposed to.

    I receive data as text. I combine two fields, then hit a macro button to convert it to General format. Pretty simple. Here is the original macro:

    Sub General_Format()
    '
    ' General_Format Macro
    '

    '
    ActiveCell.Select
    Selection.NumberFormat = "General"
    ActiveCell.Select
    SendKeys "{F2}", True
    SendKeys "{ENTER}", True
    ActiveCell.Offset(-1, 0).Select
    End Sub


    In the attached file, cell B3 has the formula I typed. When I hit the macro, it should change the format to General, hit F2 (I don't know why I have to do this to get it to "take", but I do), then hit Enter. Then I have it move back up a cell, since hitting Enter moves down one cell.

    Cell B2 shows what happens when I do the above manually, but I don't know why the macro no longer works properly.

    After some checking online, I tried adding in a Wait line, but that didn't fix it.

    Any help is appreciated!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Macro with Sendkeys no longer works

    What are you trying to accomplish that you HAVE to use sendkeys?
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro with Sendkeys no longer works

    Have you tried changing the format of column B to General to manual and then adding the formulas?
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    08-08-2013
    Location
    Colorado, USA
    MS-Off Ver
    365
    Posts
    44

    Re: Macro with Sendkeys no longer works

    Exactly what I explained in my original post and in the example.

    I can change the format of the cell to general, but when I do, I still see the formula, not the result. I can't copy it down, because it copies the same formula, referring to the same cells as the original. The only way I've found to deal with that is to hit F2 then hit Enter, then go back to the cell (because hitting Enter moves down a cell, per my desired settings). I do this often enough that it made sense to have a macro that does it so I can click a button.

    I'm certainly open to a better way to do it.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro with Sendkeys no longer works

    When I changed the format to General and copied down the formula in B2 I only got the results not the formulas.

    The only other change I made was removing the + from =+ but even if I don't do that the result is the same.

  6. #6
    Registered User
    Join Date
    08-08-2013
    Location
    Colorado, USA
    MS-Off Ver
    365
    Posts
    44

    Re: Macro with Sendkeys no longer works

    Norie, that works, but it's quicker if I do it with my method. Saves steps. I could probably write a macro to change the format of the current column to General, which I will do if I can't get this one to work. Thanks for the suggestion.

  7. #7
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Macro with Sendkeys no longer works

    Can you not convert the entire column to general, type the formula once then drag it down, so you dont have to bother with the vba at all?

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro with Sendkeys no longer works

    Here's code that'll changes the column format to General and copies the formula down.
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-08-2013
    Location
    Colorado, USA
    MS-Off Ver
    365
    Posts
    44

    Re: Macro with Sendkeys no longer works

    Norie, I use this in a lot of different files, so it's not always the same formula, but I can write a macro that will both insert the column (that's usually the first step) then format it as General, and that should solve my problem.

    If you have the time and inclination, how would I then get it to wait until I put the formula in, then copy it down for me, then paste the values where the formula is?

    (It's like asking the smart kid to do my homework for me.)

    Thanks!

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro with Sendkeys no longer works

    The formula doesn't need to be hard-coded.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Macro no longer works
    By rkorinko in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-30-2014, 01:40 PM
  2. Sendkeys CTRL+F1 sometimes works, sometimes only sends F1?
    By Haze1434 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2014, 05:33 AM
  3. Unmerge macro no longer works, needs some tweeking!
    By MZing81 in forum Excel General
    Replies: 0
    Last Post: 06-19-2012, 10:40 PM
  4. 'SendKeys' no longer works
    By aca in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 01-06-2010, 07:05 AM
  5. After formatting PC and reinstall Office macro no longer works.
    By oteixeira in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-19-2008, 10:43 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1