+ Reply to Thread
Results 1 to 10 of 10

Macro Recognizes Single Digit Month (ex: Jun = 6) But Not Double Digit Month (Nov = 11) ??

  1. #1
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Macro Recognizes Single Digit Month (ex: Jun = 6) But Not Double Digit Month (Nov = 11) ??

    Duplicate posting.
    Last edited by Logit; 03-19-2019 at 03:26 PM.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Macro Recognizes Single Digit Month (ex: Jun = 6) But Not Double Digit Month (Nov = 11

    .
    The following macro will successfully bring up the correct YEAR FOLDER and MONTH FOLDER if the month listed in L6 is a single digit ( Jan = 1; June = 6, etc.).
    However, if the month is a double digit (Nov = 10; Oct = 11, Dec = 12), the macro fails.

    Why and what change must be made to correct this error ?

    Please Login or Register  to view this content.
    The macro is currently set for the C DRIVE. In order to test there should be FOUR FOLDERS each named for a year : 2016, 2017, 2018, 2019

    Each year folder should have a folder for each month: Jan, Feb, Mar, Apr, May, etc. etc. Three letter abbreviation only.

    The attached workbook is already formatted (Sheet1, L6) properly. Enter a date in L6 (ex: 1/2/2016) and the macro will successfully open the year and
    month folders. Enter a two digit month (ex: 11/15/2018) and the macro fails.

    Why ??? What is the correction to the macro ?

  3. #3
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Macro Recognizes Single Digit Month (ex: Jun = 6) But Not Double Digit Month (Nov = 11

    If L6 contains a valid date use
    Please Login or Register  to view this content.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Macro Recognizes Single Digit Month (ex: Jun = 6) But Not Double Digit Month (Nov = 11

    I don't know why it works at all. I would suggest working with the actual date instead of trying to parse it as a string:

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro Recognizes Single Digit Month (ex: Jun = 6) But Not Double Digit Month (Nov = 11

    Hello Logit,

    Hi Buddy, you have "Dim LValue As String" without using it in your Code?

    Have you tried to Dim the LResult & LValue as Double?

    Just guessing here.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  6. #6
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro Recognizes Single Digit Month (ex: Jun = 6) But Not Double Digit Month (Nov = 11

    Hello Logit,

    I believe that 6StringJazzer might have provided a solution. Beats me how he could come up with such an idea.

    @ 6StringJazzer,

    How are you keeping my dear friend?

  7. #7
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Macro Recognizes Single Digit Month (ex: Jun = 6) But Not Double Digit Month (Nov = 11

    .
    Hey all !! (and Winon too ... )

    Thank you for the suggestions. Let me "ponder" on your solutions (I am certain they are correct).

    Be right back ....

  8. #8
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Macro Recognizes Single Digit Month (ex: Jun = 6) But Not Double Digit Month (Nov = 11

    .
    Yes ... your suggestions are 'dead on'. Thank you all for your assistance.

    Winon: the ""Dim LValue As String"" was something left over from a previous attempt at failing.


    I figure by the time I finally go home, I might learn enough here to actually write some code ! And it will
    be all because of you guys.

    Thanks again !!!!!

  9. #9
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro Recognizes Single Digit Month (ex: Jun = 6) But Not Double Digit Month (Nov = 11

    You are welcome Logit,

    Glad we could assist, and thank you for the Rep+. I appreciate it.

    Kind regards.

  10. #10
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Macro Recognizes Single Digit Month (ex: Jun = 6) But Not Double Digit Month (Nov = 11

    Thanks for the rep
    Having seen 6Stringjazzer' reply I realised I mucked up, the month part of the first formula shouldn't be there.

+ 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 to convert WBS single digit numbers to double digit numbers
    By LeanAccountant in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 06-09-2018, 05:25 AM
  2. Return double digit month
    By quartz in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-20-2017, 05:05 AM
  3. [SOLVED] Recognize single digit number as month for subtraction
    By amartin575 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-20-2017, 04:10 PM
  4. [SOLVED] Convert two digit month (ex 10) to full Month Name in Variable
    By orozvik in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-30-2015, 05:42 PM
  5. [SOLVED] LOTTERY FILTER#4, Find if 1 Digit Sum of 2 Digit or 3 Digit, Single Cell w/ dash
    By david gonzalez in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-08-2014, 12:57 AM
  6. Return name of month based on single digit number
    By fredthehead in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-09-2008, 04:46 PM
  7. [SOLVED] how to convert single digit to month name
    By cygnus in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-27-2006, 05:40 PM

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