Basic (i think) VBA help with row of data

bergman99

New Member
Joined
May 5, 2014
Messages
8
First off, thanks for your time, even if you've only gotten this far.

I have a large range of data, very little of it is useful. from CF3:ET3 the cells contain either a 0 or an 11 character string of numbers/symbols. There can be up to 5 of those strings in one row. I would like to know how to write a code that looks from CF3:ET3 and copies any of the strings found into EV3:EZ3. If it only finds one string then it would be nice if it pasted it into EV3. Finds two strings, first one to EV3 second one into EW3... so on and so forth.

My data goes from CF3:ET1130, but each row is unique and needs the 5 "report columns"


Here's a really rough example of what the data looks like...
ValuesValuesValuesValuesValuesValuesValuesValuesValuesValuesValues Report CellReport CellReport CellReport CellReport Cell
my.lil.pony0is.93.years.old00000000 my.lil.ponyis.93.years.old

<colgroup><col span="11"><col><col span="5"></colgroup><tbody>
</tbody>

Any ideas?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
The size of your file will probably take a few seconds for this to run. Maybe somebody smarter than me can come up with a faster method. This should be copied to your standard code module 1. To access the code module, press Alt + F11. The workbook should be saved as a macro enabled workbook if you intend to keep the code for future use. It will only seek out strings with 11 characters and will only put them into the five columns specified, even if there are more than five strings in the search range that meet the criteria.
Code:
Sub findString()
Dim rng As Range, c As Range, i As Long, col As Long
    With Sheets(1) 'Edit sheet name
        For i = 3 To 1130
            Set rng = .Range(.Cells(i, "CF"), .Cells(i, "ET"))
            col = 0
            For Each c In rng
                If Len(c) = 11 Then
                    st = .Cells(i, "EV")
                    st.Offset(0, col) = c
                    col = col + 1
                End If
                If col = 5 Then Exit For
            Next
        Next
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,490
Messages
6,113,956
Members
448,535
Latest member
alrossman

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