Skip to content

Instantly share code, notes, and snippets.

@geekontheway
Last active August 29, 2015 13:57
Show Gist options
  • Save geekontheway/9813554 to your computer and use it in GitHub Desktop.
Save geekontheway/9813554 to your computer and use it in GitHub Desktop.
VBA FOR RACHEL
Function GETCITYNAME(district As Range, cities As Range) As String
Dim X As Range
For Each X In cities
If InStr(1, district.Value, X.Value) > 0 Then
GETCITYNAME = X.Value
Exit For
End If
Next X
End Function
Function RIGHTREMOVESTR(cell As Range, str As String) As String
Dim Index As Interger
rem 获得从右开始匹配字符串的位置,即终止位置
Index = InstrRev(Len(cell.Value), str)
rem 获得终止位置之前的字符串
RIGHTREMOVESTR = Left(cell.Value, Index-1)
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment