Monday, January 30, 2012

Use Split Function in UDF to pick a word at specific number from a cell separated by special characters

if you cell value is separated by a space or comma etc. and you want to pic 2nd word or 3 rd etc form a cell without applying text to column or find ,etc. Snapshot below

Here is the udf

Function pick_word(x As String, spl As String, positon As Integer)
Dim z
z = split(x, spl)
pick_word = z(positon - 1)
End Function

Type like pick_word(A3," ",2)

a3 - is cell having value

" " - space is used as separator

2 - which word to be picked

No comments:

Post a Comment

Import data from SQL

Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...