Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Macro to Function

The below macro works perfect. It extracts the name from a text. How
can I change below macro into "Public Function" Please can any friend
can help

Sub GetNames()
For Each Cell In Range("A1:A4")
Text = Replace(Split(Cell, "\")(UBound(Split(Cell, "\"))), ".", " ")
Parts = Split(Text, " ", 3)
Parts(2) = ""
Cell.Offset(0, 1).Value = Trim(Join(Parts))
Next
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Macro to Function

It's a subroutine... exactly what do you mean by "change [it] to a public
**function**"?

--
Rick (MVP - Excel)


"K" wrote in message
...
The below macro works perfect. It extracts the name from a text. How
can I change below macro into "Public Function" Please can any friend
can help

Sub GetNames()
For Each Cell In Range("A1:A4")
Text = Replace(Split(Cell, "\")(UBound(Split(Cell, "\"))), ".", " ")
Parts = Split(Text, " ", 3)
Parts(2) = ""
Cell.Offset(0, 1).Value = Trim(Join(Parts))
Next
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Macro to Function

basically i need function to exctract name from text

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Macro to Function

I don't remember your original data, but I think this function will do what
you want...

Function GetName(S As String) As String
Dim Parts() As String
GetName = Replace(Split(S, "\")(UBound(Split(S, "\"))), ".", " ")
Parts = Split(GetName, " ", 3)
Parts(2) = ""
GetName = Trim(Join(Parts))
End Function

--
Rick (MVP - Excel)


"K" wrote in message
...
basically i need function to exctract name from text


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Macro to Function

Thanks lot rick
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF Macro / Function Kimmon Excel Worksheet Functions 8 December 9th 08 03:40 PM
Macro + IF Function? Gunti Excel Discussion (Misc queries) 1 December 9th 08 09:08 AM
If function in Macro Rick Excel Programming 11 August 9th 08 03:07 PM
Sub Macro vrs Function Macro Auto Start Pat Excel Discussion (Misc queries) 7 June 6th 07 09:53 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM


All times are GMT +1. The time now is 02:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"