Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8795335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:22:23+00:00 2026-06-13T23:22:23+00:00

ISSUE Large dataset with many improperly or non-uniformly entered dates in a specific field.

  • 0

ISSUE

Large dataset with many improperly or non-uniformly entered dates in a specific field. There are about 19 different ways the dates have been entered in about 60,000 records. Some entries are completely invalid and must be discarded, others must be formatted properly. I am loading the range into an array and then performing the operations. I wrote out the operations as I believe I need, however I need some help in actually getting them working. See code below; error in comments.

CURRENT PROBLEM

For entries like ’54 Days’ the following code should only take the characters to the left of the space, and then check if they are numeric. If they are, it keeps them, if they are not it empties that array element. In practice, nothing is happening, I still have the full entry in the array element?

ElseIf delType = "String" And Len(del(i, 1)) < 10 And InStrRev(del(i, 1), " ") Then 'Takes the number from entries like 2194 Days or 23 DPD
    del(i, 1) = Left(del(i, 1), Len(del(i, 1)) - InStrRev(del(i, 1), " "))
    If IsNumeric(del(i, 1)) = False Then 'If the characters to the left of the space are not numbers, discard
        del(i, 1) = Empty
    Else
        del(i, 1) = Format((CLng(Range("E" & i + 1).Value) - Abs(del(i, 1))), "mm/dd/yy") 'Pull order date and subtract days from it for delinquency date
    End If

ENTRY TEMPLATES

SEPT. 25, 20 (No year, no year! Delete.)
SEPT (No year, useless, delete.)
N/A (Rubbish! Deleted.)
LONG TIME AG (What moron thought this was a good idea, delete.)
JUNE 30, 200 (Apparently the field will only hold 12 characters, delete.)
CHARGED OFF (Useless, delete.)
94 DAYS (Take all characters preceding space and subtract from other field containing order date to obtain delinquent date.)
94 DPD (DPD in someones bright mind stands for Days Past Due I believe. Same as above.)
2008-7-15 12 (Not sure what additional number is, take all characters before space and transform.)
INVALID (Delete.)
BLANK (Do nothing.)
12282009 (Use nested LEFT and RIGHT and CONCATENATE with / in between.)
9202011 (Add leading zero, then same as above.)
92410 (Add leading zero, this will transform to 09/24/10)
41261 (Days since 31/12/1899, this will transform to 12/08/12)
1023 (Days since delinquent, subtract from ORDER DATE to get delinquent date.)
452 (Same as above.)
12 (Same as above.)
1432.84 (Monetary value, mistakenly entered by low IQ lackey. Delete.)

CODE (WORK IN PROGRESS)

'Perform housekeeping on delinquency date
Columns("AH:AH").Select
Selection.NumberFormat = "0"
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    True, Transpose:=False
Dim del()
ReDim del(1 To importwsRowCount, 1 To 1)
del = Range("AH1:AH" & importwsRowCount).Value
Dim delChars As Long
Dim delType As String
For i = LBound(del, 1) To UBound(del, 1)
    delChars = Len(del(i, 1)) 'Determine length of entry
    If IsNumeric(del(i, 1)) = True Then 'Determine datatype of entry
        delType = "Numeric"
    Else
        delType = "String"
    End If
    If InStr(del(i, 1), ".") Then 'Removes monetary entries like 142.84
        del(i, 1) = Empty
    ElseIf InStr(del(i, 1), "*") Then 'Removes ***INVALID*** entries
        del(i, 1) = Empty
    ElseIf delChars = 12 Then 'Removes all entries that extend beyond the 12 character limit of the field and get cut off
        del(i, 1) = Empty
    ElseIf delType = "String" And Len(del(i, 1)) < 10 And InStrRev(del(i, 1), " ") Then 'Takes the number from entries like 2194 Days or 23 DPD
        del(i, 1) = Left(del(i, 1), Len(del(i, 1)) - InStrRev(del(i, 1), " "))
        If IsNumeric(del(i, 1)) = False Then 'If the characters to the left of the space are not numbers, discard
            del(i, 1) = Empty
        Else
            del(i, 1) = Format((CLng(Range("E" & i + 1).Value) - Abs(del(i, 1))), "mm/dd/yy") 'Pull order date and subtract days from it for delinquency date
        End If
    ElseIf delType = "Numeric" And Len(del(i, 1)) = 5 Then
        If del(i, 1) > CLng(Date) Then 'Value is greater than todays date, improperly formated date that needs character manipulation and / added
            del(i, 1) = Format(del(i, 1), "000000") 'Add leading zero
            del(i, 1) = DateSerial(Right(del(i, 1), 2), Left(del(i, 1), 2), Right(Left(del(i, 1), 2), 4)) 'Grab year, then month, then day for serialize
        Else
            del(i, 1) = Format(del(i, 1), "mm/dd/yy") 'Properly formated date that just needs format conversion
        End If
    ElseIf delType = "Numeric" And (delChars = 7 Or delChars = 8) Then
        If delChars = 7 Then
            del(i, 1) = Format(del(i, 1), "00000000") 'Add leading zero
        End If
        del(i, 1) = DateSerial(Right(del(i, 1), 4), Left(del(i, 1), 2), Right(Left(del(i, 1), 2), 6)) 'Grab year, then month, then day for serialize
    ElseIf delType = "Numeric" And delChars < 5 Then
        del(i, 1) = Format((CLng(Range("E" & i + 1)) - Abs(del(i, 1))), "mm/dd/yy")
    End If
Next i
Set delRange = Range("AJ1:AJ" & importwsRowCount)
iWS.names.Add Name:="dRange", RefersTo:=delRange
Range("dRange").Value = del 'Write array to worksheet
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:22:23+00:00Added an answer on June 13, 2026 at 11:22 pm

    “54 Days” contains 7 characters so Len("54 Days") is 7

    The space character occurs in position 3 and InStrRev("54 Days", " ") returns 3

    So, we have Left("54 Days", 7 - 3) which produces "54 D" which is obviously not numeric

    Perhaps try Left(del(i, 1), InStrRev(del(i, 1), " ") - 1) instead

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with a large dataset of products(~1 million). These products come from many
I am attempting to work with a very large dataset that has some non-standard
I am having an issue with importing a large(60MB) CSV file in MYSQL DB.
We're having an issue on one of our fairly large websites with spam bots.
The select statements are quite large so in a simplified presentation my issue is:
Here is my issue. I have a SearchViewModel that has a large number of
I have a very large ASP.NET application in C#. The issue is simple yet
I have a relatively large dataset of items (a few thousand items) that I
I have an issue with manipulating large number of record objects of type ActiveRecord
Issue I have recently found myself working with a large, unfamiliar, multi-department, C++ codebase

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.