vb code require, to understand format in cell value

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I have given. See my post no. #10 . Col A contains data.

and Col B require the output as mentioned.
and Col C require the output in date format.

This is the only im trying to do..

Still waiting for you to provide a sample of data and desired output.
 
Upvote 0
I don't think this can be done because there don't appear to be any consistent rules to your data.
 
Upvote 0
That's the reason, now i will write a single single code to every type..That is the only solution..

If I require, help on any type..please revert and suggest. Thanks till here... A much appreciated for your reply.

I don't think this can be done because there don't appear to be any consistent rules to your data.
 
Upvote 0
Hey Neil,
Could you please suggest on this..
It giving me Type mismatch error..bcoz variable b taken as String...how to fix this..
Code:
Sub test()
Dim i As Integer
Dim b As String
Dim space As Long
 
Application.ScreenUpdating = False
i = Range("B" & Rows.Count).End(xlUp).Row
For b = 3 To i
'b = Range("A3")
If b Like "[A-Z][A-Z][A-Z]-[A-Z][A-Z][A-Z][A-Z][A-Z] #-##" Then
    space = WorksheetFunction.Find(" ", b)
    Range("B3") = Left(b, space - 1)
    Range("C3") = Right(b, Len(b) - space)
End If


'b = Range("A4")
If b Like "[A-Z][A-Z][A-Z][A-Z][0-9][0-9][0-9][0-9][A-Z][A-Z] ([0-9][0-9]/[0-9][0-9])" Then
    space = WorksheetFunction.Find(" ", b)
    Range("B4") = Left(b, space - 1)
    Range("C4") = Right(b, Len(b) - space)
End If


Next
Application.ScreenUpdating = True
End Sub
I don't think this can be done because there don't appear to be any consistent rules to your data.
 
Upvote 0
My bad- try this...

Code:
Sub test()
Dim LastRow As Long
Dim i As Integer
Dim b As String
Dim space As Long
 
Application.ScreenUpdating = False
LastRow = Range("B" & Rows.Count).End(xlUp).Row
For i = 3 To LastRow
    b = Cells(i, 1)
    If b Like "[A-Z][A-Z][A-Z]-[A-Z][A-Z][A-Z][A-Z][A-Z] #-##" Then
        space = WorksheetFunction.Find(" ", b)
        Range("B3") = Left(b, space - 1)
        Range("C3") = Right(b, Len(b) - space)
    End If
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Neil, Thanks for this...But I think yesterday while showing you actual data...We skip one problem..in post #9
i.e. In Col C, for below example..
UTS-COVPG 7-03
it is coming..

Wherein, 7 is the Month and 03 is the Year.
Therefore, Col C require like this..
..

Can we amend this..
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,976
Messages
6,133,832
Members
449,836
Latest member
MeltedVision

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