View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Erin Erin is offline
external usenet poster
 
Posts: 75
Default Mid and Find in macro

I tried both of those but couldn't get either to work. I used "Selection"
instead of "mystring" since I'm using "Range("A1").Select" in the code. I
get the following errors:


Invalid procedure call or argument (for the first string)

Unable to get the Find property of the worksheetFunction class (for the
other string)

What am I missing?




"Mike H" wrote:

erin,

I should have added that to do it 'your' way it looks like this

myotherstring = Trim(Mid(Range("A1"), WorksheetFunction.Find(" ",
Range("A1")), 255))

Mike

"Mike H" wrote:

Erin,

Use VB native instr function which finds the position of a character in a
string

mystring = Trim(Mid(Range("A1"), InStr(Range("A1"), " ")))

Mike

"Erin" wrote:

Hi!

I'm trying to use this type of formula in a macro, but I can't figure out
the syntax:

Trim(MID(A1,FIND(" ",A1),255))

So if I have "Alpha Dog" in a cell, I want to only show "Dog". The length
of each word or number will vary and there could be multiple spaces between
them.

Appreciate any help!