0

I have two strings:

1. #ck#
2. #c44#

these are located in a string like

"#CK# Site B: Umbau der IDU vom in Delta-Cabinets und Auflage der STM-1 auf ODF"

I am unable to use a function that is similar to isnumber(search) in Excel. I want to find #ck# or #c44# in a string and then use iif for further naming it to something more meaningful.

Andre
  • 26,751
  • 7
  • 36
  • 80
Mani
  • 35
  • 1
  • 5
  • 1
    Have you tried the `Replace()` function? Or `InStr()` to see if a string is contained in another string. – Andre Mar 06 '16 at 00:03
  • I have tried inst() but was unable to get what was actually required. – Mani Mar 06 '16 at 10:41

1 Answers1

0

I have used two ways to find your strings. First, if I place your string in Cell(1,1) (I also added the #c44# to that string) in Cell(1,2) I entered formula:

=FIND("#c44#",A1,1)

Note that the CASE must match or it will not find the string!

The second method is the following Function

Option Explicit

Function Find_Pound()
Dim strString   As String
Dim strFind1    As String
Dim i           As Integer

'"#CK# Site B: Umbau der IDU vom in Delta-Cabinets und Auflage der #c44# STM-1 auf ODF"
    strString = Sheet1.Cells(1, 1)      
    strFind1 = "#CK#"
    i = InStr(1, strString, strFind1)
    If i > 0 Then
        MsgBox "Found: '" & strFind1 & "' at position: " & i
    End If

    strFind1 = "#c44#"
    i = InStr(1, strString, strFind1)
    If i > 0 Then
        MsgBox "Found: '" & strFind1 & "' at position: " & i
    End If

End Function
Wayne G. Dunn
  • 4,282
  • 1
  • 12
  • 24