+ Reply to Thread
Results 1 to 8 of 8

extract serial number of a date from a textbox input

  1. #1
    Registered User
    Join Date
    11-17-2011
    Location
    Philippines
    MS-Off Ver
    MS Office 2010 to 2013
    Posts
    22

    Exclamation extract serial number of a date from a textbox input

    Hi, I have these codes as a part of my project.

    Please Login or Register  to view this content.
    Basically, what I am trying to do is compare if a new record is a duplicate value. But when I try to run debug, CDATE can convert the textboxDate.value (say 3/31) to 3/31/2013 but xdate is 0. I need a way to extract the serial number of a date so I can compare it to range H1:H50000 which has the corresponding serial numbers of the previously entered records. I am not even sure if the other parts of the codes above are correct or would work, I just want to learn how to extract the serials. Please help.

    TIA,
    Steve

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: extract serial number of a date from a textbox input

    Two Questions:-

    1. Whether "H1:H50000" is having Text Date's instead of real dates? since Format converts real date to text.
    2. If "H1:H50000" is text date then change this Dim xdate As Long to Dim xdate As string


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    11-17-2011
    Location
    Philippines
    MS-Off Ver
    MS Office 2010 to 2013
    Posts
    22

    Re: extract serial number of a date from a textbox input

    Quote Originally Posted by :) Sixthsense :) View Post
    Two Questions:-

    1. Whether "H1:H50000" is having Text Date's instead of real dates? since Format converts real date to text.
    2. If "H1:H50000" is text date then change this Dim xdate As Long to Dim xdate As string
    Sorry, I mentioned that H1:H50000 contains the serial numbers of previously entered dates, is that text date? The sheet that I am working on is actually an old project. I just want to add some VBA codes to it since I plan to use a userform as an input option. So there are records already in it.
    Last edited by rsbuslon; 03-20-2013 at 01:05 AM.

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: extract serial number of a date from a textbox input

    I am not sure what do you mean by the word serial numbers if the entered date is real date then the each date value will show in the right side of the cell (Check it by removing the Center, Left, Right alignments).

    Please check and confirm

  5. #5
    Registered User
    Join Date
    11-17-2011
    Location
    Philippines
    MS-Off Ver
    MS Office 2010 to 2013
    Posts
    22

    Re: extract serial number of a date from a textbox input

    Sorry, I'm not even sure if I am using the right term. But other people from other forums are calling it as such so I thought,,,, you know.

    Anyway, say A1 has a date, 3/31/2013. And in B1, we put =VALUE(A1), which will give us the serial number of the date as 41364. Again I don't know the correct term for that. LOL. This also appears if instead of Date, a cell is formatted as Text instead with date in it.

    I'm trying to figure out how to extract that numerical value (serial number in my world) and use it to the above expression.

    I tried Dim xdate as string also, but it returned xdate = "" in debug.

    I'm desperate,
    Last edited by rsbuslon; 03-20-2013 at 01:27 AM.

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: extract serial number of a date from a textbox input

    You have mis understood my question.

    I need to know whether the dates are in H1:H50000 is real date or text date? or if you are having the =value(TextDate) converted date's in separate column then what is the column reference?
    Because If the SOURCE date is in Text Format and comparing the (form Date - Real Date) with Text date in Countif will not get the expected result.

  7. #7
    Registered User
    Join Date
    11-17-2011
    Location
    Philippines
    MS-Off Ver
    MS Office 2010 to 2013
    Posts
    22

    Re: extract serial number of a date from a textbox input

    Got it working finally with the below code. I don't know that I was already doing what is right. I then used this to a Select statement and got the desired results.

    Please Login or Register  to view this content.
    something like that. thanks for the help Sixthsense

  8. #8
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: extract serial number of a date from a textbox input

    Glad you solved it

+ 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