+ Reply to Thread
Results 1 to 7 of 7

clean code from recorded macro

  1. #1
    Registered User
    Join Date
    06-22-2011
    Location
    location
    MS-Off Ver
    Excel 2007
    Posts
    47

    clean code from recorded macro

    Hi guys,

    I have a wkb and if I make some changes in it and then try to work at office, the hours show "h:mm". I have recorded a macro in order to set "hh:mm" for some cells.
    because I have more than 50 sheets is possible ot have it ...shorter than I got it?
    the sheets are named as:
    "stu-2437"
    "stu-567A"
    "stu-700ABC"
    "stu-item1" to "stu-item12"
    I appreciate your help!

    regards, Tim

    Please Login or Register  to view this content.
    Last edited by tim5; 02-07-2012 at 12:22 PM.

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: clean code from recorded macro

    Hi tim5, try
    Please Login or Register  to view this content.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Registered User
    Join Date
    06-22-2011
    Location
    location
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: clean code from recorded macro

    hi Mordred,

    Thank you very much for yr help! nice, fast and helpful!
    hope it won't affect other sheets!

    greatly appreciated!

    regards,Tim

  4. #4
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: clean code from recorded macro

    It's going to affect every sheet in the workbook. If you only want specific sheets affected then add the do something like:
    Please Login or Register  to view this content.
    Except now you'll have to code for each specific sheet in your workbook. You could probably use Select Case (see here).

  5. #5
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: clean code from recorded macro

    This is not tested because I don't have your workbook but perhaps:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-22-2011
    Location
    location
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: clean code from recorded macro

    hi,
    I know it affects all sheets, but the range of the others sheets is outside and some of them have text!
    thank you for sending me to "Select case", I think it's .... a little bit complicated for me, I'll try to "decrypt" it!

    regards, Tim

    edit: I see what select means...well, I have too many sheets for using it! I use the first code you provided!
    I call you if I encounter problems!
    Last edited by tim5; 02-07-2012 at 12:48 PM.

  7. #7
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: clean code from recorded macro

    If it doesn't work or you need help understanding it, just let me know.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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