View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default How to extract data from File Path


How can it extract the values and yet still give an error?
On what line does the error occur?
I suspect you have some short file paths and var(3) does not exist.
'--
Use Option Explicit at the top ot the module.
Declare all variables
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"DK"
wrote in message
Hi Jim
Thanks for your help!!

I have modified the code to this:-
Sub Macro2()
'
Dim var As Variant
For Each rCell In Range("D2:D65536")
var = VBA.Split(rCell.Text, "\", -1)
rCell.Offset(0, 3).Value = var(2)
rCell.Offset(0, 4).Value = var(3)
Next
End Sub

It extracted the values but gives me an error Subscript out of range.
Am I doing something wrong?

Thanks again!!
On Jun 13, 2:43 pm, "Jim Cone" wrote:
For Each rCell in rngCol.Cells
var = VBA.Split(rCell.Text, "\", -1)
rCell.Offset(0, 3).Value = var(2)
rCell.Offset(0, 4).Value = var(3)
Next
--
Jim Cone
San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware

"DK" wrote in message

Jim,
Where are we specifying the column that would have the result? I don't
need it to show up in a Msg Box. I have about 35000 rows which have
the same kind of format. The File Path data is in Column D and the
data needs to be extracted in Col G & H.