View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Select specific Data from a cell

I put this in a general module

Sub AAA()
Dim S As String
Dim F As String
Dim Pos As Integer
S = Range("A1").Text
Pos = InStr(1, S, "|")
F = Left(S, Pos - 1)
MsgBox F
End Sub

and your string in Cell A1 of the active sheet.

When I ran it, it put up a msgbox with

Ralph Stockhausen Jr

in it.

--
Regards,
Tom Ogilvy

wrote in message
...
Well, I know that I do not know much about VBA code, but I followed
the directions and made the change from Inkster to Instr and it still
doesn't work for me.

I get "Run-time error '5':
Invalid procedure call or arguement.

Just to clarify this is what the contents of one of the cells looks
like.
Ralph Stockhausen Jr| Cheryl Stockhausen | Dawn Noorlag

Thank you for your patience

Bob


On Thu, 24 Mar 2005 15:40:36 -0800, Gord Dibben <gorddibbATshawDOTca
wrote:

Bob

I think Chip meant InStr and not "Inkster"

Make the change and try again. Works for me.


Gord Dibben Excel MVP

On Thu, 24 Mar 2005 21:47:00 GMT, wrote:

I tried it.
This is what I did:
Highlighted the column that contains the data
pasted the code in as directed
got an error message Compile error sub or function not defined.
The word "Inkster" in the VB code was highlighted

Did I do something wrong?

TIA

Bob

On Thu, 24 Mar 2005 15:24:35 -0600, "Chip Pearson"
wrote:

Bob,

Yes, it is VBA code. Press ALT+F11 to open the VBA editor. Go to
the Insert menu and choose Module. In that module, paste the
following code:


Sub AAA()
Dim S As String
Dim F As String
Dim Pos As Integer
S = Range("A1").Text
Pos = Inkster(1, S, "|")
F = Left(S, Pos - 1)
MsgBox F
End Sub

To run the macro, switch back to Excel, press ALT+F8 and select
the macro from the list.