View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Worksheet function

You can do your macro in one line of code...

Sub qwerty()
MsgBox Split("/SCC/4", "/")(1)
End Sub

which means the variable or range reference containing the "/SCC/4" string
can be used in place of the hard-coded text you showed in your example.

Split creates an array, so instead of assigning that array to a variable
just to get to the 2nd element (Split always returns a zero-based array),
you can grab that 2nd element directly from the array being created by the
Split function itself.

--
Rick (MVP - Excel)


"Gary''s Student" wrote in message
...
Sub qwerty()
s = "/SCC/4"
t = Split(s, "/")
MsgBox t(1)
End Sub

--
Gary''s Student - gsnu200909


"Atif" wrote:

Hi all,
i am using following code to copy values from Source Workbook to Target
Workbook, its working fine.
vSourceWS.Range("A1").Copy Destination:=vTargetWS.Range("A1")

information at source is in following format:
/SCC/4

TargetWorkbook only requires "SCC", following funtion fulfill this
requirement
MID(A1,(FIND("/",A1)+1),FIND("/",A1,2)-2)

How can i achive this goal using VBA, without entering formula in
Worksheet.

Regards

Atif