Need modification in code. New Condition & New Logic.

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,284
Office Version
  1. 365
Platform
  1. Windows
I need help on this code..Need some modification in it..and addition of some more condition...

I really work hard to understand, but really I'm not that much, to insert any new condition..

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
 
Dear All, I really need help on this...Please revert..


Story was, previously i have limited "Form number with Date". Now some new "Form numbers" are seen.

Hence, need to incorporate this all..
In first i.e. in Col B having "Form number with Date".
Output Columns are-
Col E - Form Numbers only
Col F - Date only

can we do something..
[TABLE="width: 720"]
<tbody>[TR]
[TD]Form Number with Date[/TD]
[TD]Form Number[/TD]
[TD]Date (M/D/YYYY)[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]EPP-E122-0116[/TD]
[TD]EPP-E122[/TD]
[TD="align: right"]1/1/2016[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]10-02-2543 (10/16 ed.)[/TD]
[TD]10/2/2543[/TD]
[TD="align: right"]10/1/2016[/TD]
[TD]---here "ed." not required[/TD]
[/TR]
[TR]
[TD]14-02-1350 (1/95 ed.)[/TD]
[TD]14-02-1350[/TD]
[TD="align: right"]1/1/1995[/TD]
[TD]---here "ed." not required[/TD]
[/TR]
[TR]
[TD]AXIS 102 A/C (06 15)[/TD]
[TD]AXIS 102 A/C[/TD]
[TD="align: right"]6/1/2015[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]EP 4104 (06 13)[/TD]
[TD]EP 4104[/TD]
[TD="align: right"]6/1/2013[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]EP 1051-CA (07 13)[/TD]
[TD]EP 1051-CA[/TD]
[TD="align: right"]7/1/2013[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]CC-1k11H (03/14)[/TD]
[TD]CC-1k11H[/TD]
[TD="align: right"]3/1/2014[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]XSC-27266 (05/09)[/TD]
[TD]XSC-27266[/TD]
[TD="align: right"]5/1/2009[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]EXL 0001 0615[/TD]
[TD]EXL 0001[/TD]
[TD="align: right"]6/1/2015[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]05 PCD0071 00 03 10[/TD]
[TD]05 PCD0071 00[/TD]
[TD="align: right"]3/1/2010[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]00 ML0012 00 09 04[/TD]
[TD]00 ML0012 00[/TD]
[TD="align: right"]9/1/2004[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]IL 00 17 01 98[/TD]
[TD]IL 00 17[/TD]
[TD="align: right"]1/1/1998[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]HC00051212[/TD]
[TD]HC0005[/TD]
[TD="align: right"]12/1/2012[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]HC70010605[/TD]
[TD]HC7001[/TD]
[TD="align: right"]6/1/2005[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]IL P 001 01/04[/TD]
[TD]IL P 001[/TD]
[TD="align: right"]1/1/2004[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]RHIC 6000 08/11[/TD]
[TD]RHIC 6000[/TD]
[TD="align: right"]8/1/2011[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]ACF-7007 Ed. 08-11[/TD]
[TD]ACF-7007[/TD]
[TD="align: right"]8/1/2011[/TD]
[TD]---here "Ed." not required[/TD]
[/TR]
[TR]
[TD]DX T1 00 11 12[/TD]
[TD]DX T1 00[/TD]
[TD="align: right"]11/1/2012[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]DX 00 04 11 07[/TD]
[TD]DX 00 04[/TD]
[TD="align: right"]11/1/2007[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]17-02-5205 2-98[/TD]
[TD]17-02-5205[/TD]
[TD="align: right"]2/1/1998[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]17-02-5205 7-03[/TD]
[TD]17-02-5205[/TD]
[TD="align: right"]7/1/2003[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]11-02-1220 (09/03)[/TD]
[TD]11-02-1220[/TD]
[TD="align: right"]9/1/2003[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]NOTS0021CA (09/03)[/TD]
[TD]NOTS0021CA[/TD]
[TD="align: right"]9/1/2003[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]UTS-COVPG 7-03[/TD]
[TD]UTS-COVPG[/TD]
[TD="align: right"]7/1/2003[/TD]
[TD]--before 7 there is one extra space…very rare it is coming[/TD]
[/TR]
[TR]
[TD]IL 00 17 02/2013[/TD]
[TD]IL 00 17[/TD]
[TD="align: right"]2/1/2013[/TD]
[TD]---here "Ed." not required[/TD]
[/TR]
[TR]
[TD]abcde (06 15)[/TD]
[TD]abcde[/TD]
[TD="align: right"]6/1/2015[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]EPP-POL-0410[/TD]
[TD]EPP-POL[/TD]
[TD="align: right"]4/1/2010[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]ABCDEF 02 - 01/20[/TD]
[TD]ABCDEF 02[/TD]
[TD="align: right"]1/1/2020[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]IL 1202[/TD]
[TD]IL 1202[/TD]
[TD][/TD]
[TD]--no date required[/TD]
[/TR]
[TR]
[TD]17-02-52 - 01/57[/TD]
[TD]17-02-52 - 01/57[/TD]
[TD][/TD]
[TD]--no date required[/TD]
[/TR]
[TR]
[TD]95863.2857142837[/TD]
[TD]95863.2857142837[/TD]
[TD][/TD]
[TD]--no date required[/TD]
[/TR]
[TR]
[TD]95863.28571 - 01/57[/TD]
[TD]95863.28571 - 01/57[/TD]
[TD][/TD]
[TD]--no date required[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,224,827
Messages
6,181,195
Members
453,021
Latest member
pingpong7117

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