want to separate form number and date

Status
Not open for further replies.

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,284
Office Version
  1. 365
Platform
  1. Windows
Hi All,
This is my new query..

I have this code..
Code:
Dim R As Long, X As Long, Cnt As Long, Data As Variant
Data = Range("B3", Cells(Rows.Count, "B").End(xlUp)).Resize(, 2)
For R = 1 To UBound(Data)
  Cnt = 0
  Data(R, 2) = ""
  For X = Len(Data(R, 1)) To 1 Step -1
    If Cnt < 4 Then
      If IsNumeric(Mid(Data(R, 1), X, 1)) Then
        Cnt = Cnt + 1
        Data(R, 2) = Mid(Data(R, 1), X, 1) & Data(R, 2)
      End If
    ElseIf Cnt = 4 Then
      Data(R, 2) = Format(Data(R, 2), "@@/01/@@")
      Data(R, 1) = Left(Data(R, 1), X)
      Cnt = 5
    ElseIf IsNumeric(Mid(Data(R, 1), X, 1)) Then
      Data(R, 1) = Left(Data(R, 1), X)
      Exit For
    End If
  Next
Next
Range("F3").Resize(UBound(Data)).NumberFormat = "mm/dd/yyyy"
Range("E3").Resize(UBound(Data), 2) = Data

The above code separate "form number" and "date".
Now I'm facing one challenge in this..
i found 2 form number's which are actually not giving me correct output.

i.e. in Col B
Code:
UTS-COVPG  7-03
IL 00 17 02/2013

when this separate, it giving me something wrong output..like this..
Output..which is wrong
Code:
Col E.........................Col F
UTS-COVPG  7-03.......12/3/1901
IL 00 17 02................20/01/13


Output should be..
Code:
Col E...............Col F..(MM/dd/yyyy)
UTS-COVPG.....07/01/2003
IL 00 17..........02/01/2013

Can any one able to give me something correction in code..
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
my bad..apologies, forgot to mention one more form type..where output not sound correct..

Col B
CA2OOOI (03/10)

output generating...which in-correct for Col E and Correct for Col F
Col E.........Col F
CA2..........3/1/2010

Output should be..
Col E..........Col F
CA2OOOI...3/1/2010
 
Upvote 0
Highly appriciate, some one can please guide
Hi All,
This is my new query..

I have this code..
Code:
Dim R As Long, X As Long, Cnt As Long, Data As Variant
Data = Range("B3", Cells(Rows.Count, "B").End(xlUp)).Resize(, 2)
For R = 1 To UBound(Data)
  Cnt = 0
  Data(R, 2) = ""
  For X = Len(Data(R, 1)) To 1 Step -1
    If Cnt < 4 Then
      If IsNumeric(Mid(Data(R, 1), X, 1)) Then
        Cnt = Cnt + 1
        Data(R, 2) = Mid(Data(R, 1), X, 1) & Data(R, 2)
      End If
    ElseIf Cnt = 4 Then
      Data(R, 2) = Format(Data(R, 2), "@@/01/@@")
      Data(R, 1) = Left(Data(R, 1), X)
      Cnt = 5
    ElseIf IsNumeric(Mid(Data(R, 1), X, 1)) Then
      Data(R, 1) = Left(Data(R, 1), X)
      Exit For
    End If
  Next
Next
Range("F3").Resize(UBound(Data)).NumberFormat = "mm/dd/yyyy"
Range("E3").Resize(UBound(Data), 2) = Data

The above code separate "form number" and "date".
Now I'm facing one challenge in this..
i found 2 form number's which are actually not giving me correct output.

i.e. in Col B
Code:
UTS-COVPG  7-03
IL 00 17 02/2013

when this separate, it giving me something wrong output..like this..
Output..which is wrong
Code:
Col E.........................Col F
UTS-COVPG  7-03.......12/3/1901
IL 00 17 02................20/01/13


Output should be..
Code:
Col E...............Col F..(MM/dd/yyyy)
UTS-COVPG.....07/01/2003
IL 00 17..........02/01/2013

Can any one able to give me something correction in code..
 
Upvote 0
Continuation of https://www.mrexcel.com/forum/excel-questions/1034411-vba-code-require-separate-date-code-3.html

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread. Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).

If you do not receive a response, you can "bump" it by replying to it again, though we advise you to wait 24 hours before doing and not to bump a thread more than once a day.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,909
Messages
6,175,312
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top