vba to find specific combination of chars in one column

gint32

Board Regular
Joined
Oct 8, 2014
Messages
139
Hi all
I have a column that contains free text, I need a way (using vba) to find specific chars in this column the format of the text chars will always be like .. one Alpha and 7 numeric(together).....Examples of this is are D1564567, A1235567, all the way through to Z2356457 and if and when found copy this alpha numeric to he adjacent cell on the right. Not all cells will have this so it needs to e able to skip over records that do not contain, any help appreciated
 
Great stuff.. (RX!)... thanks for the comments ..didnt realise vba do those routines..i thought arrays was as far as it could go ..
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
For this issue, double-click ThisWorkbook and paste the code below into the right hand pane that just opened.

Pete is there any way to automate this instead of pasting into this workbook, reasons being is a lot of users will not be able to do the right click and insert code, the thought of that would probably scare them to death...:)
 
Upvote 0
Pete is there any way to automate this instead of pasting into this workbook, reasons being is a lot of users will not be able to do the right click and insert code, the thought of that would probably scare them to death...:)
Where is the Find_Matches macro housed and how are users activating it?
 
Upvote 0
Some using a keyboard shortcut..and or an icon on the quick ribbon...code is located in there personal.xlsb ..within C: users username xlstart thanks..the code get copied from a network location to their personal folder via a button in a ms word that I created for ease .this is the only way i know of to run vba.
 
Last edited:
Upvote 0
Some using a keyboard shortcut..and or an icon on the quick ribbon...code is located in there personal.xlsb
Then could this work for you? Instead of the double-click, put this code in a similar location to the Find_Matches code & have the users simply select a cell in column A or B of the last (new) sheet and then run this code in a similar way to the previous code.

Code:
Sub Show_Detail()
  Dim rng As Range, c As Range
  Dim txt As String
 
  If ActiveSheet.Index = Sheets.Count Then
    If ActiveCell.Column <= 2 Then
      Set rng = ActiveCell.EntireRow.Resize(, 2)
      With Sheets("Workbook 2")
        .AutoFilterMode = False
        With .Range("A1:F" & .Range("A" & .Rows.Count).End(xlUp).Row)
          .AutoFilter Field:=1, Criteria1:=rng.Cells(1).Value, Operator:=xlOr, Criteria2:=rng.Cells(2).Value
          .AutoFilter Field:=6, Criteria1:="*" & rng.Cells(1).Value & "*", Operator:=xlOr, Criteria2:="*" & rng.Cells(2).Value & "*"
          For Each c In .Columns(1).SpecialCells(xlVisible)
            If c.Row > 1 Then txt = txt & vbLf & vbLf & c.Value & ":" & vbLf & c.Offset(, 5).Value
          Next c
        End With
        .AutoFilterMode = False
      End With
      If Len(txt) Then MsgBox txt
    End If
  End If
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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