Help with MID function

Discussion in 'Microsoft Excel Discussion' started by bobh, Jun 7, 2012.

  1. bobh

    bobh Guest

    I'm not an Excel vba person so I don't know why this doesn't work, any
    help is appericated
    I'm trying to get the first three characters of the value that's in
    cell A3 and store it in the GetVal string variable. This keeps
    erroring with the message 'Variable not defined' and it highlights the
    A3 on the GetVal line

    Dim GetVal As String
    Sheets("Dollars").Select
    Range("A3").Select
    GetVal = Mid(A3, 1, 3) <--highlights A3 after error message
    If GetVal = "Oct" then
    ....etc
    end if

    thanks
    bobh.
     
    bobh, Jun 7, 2012
    #1
    1. Advertisements

  2. bobh

    Claus Busch Guest

    Hi Bob,

    Am Thu, 7 Jun 2012 06:37:54 -0700 (PDT) schrieb bobh:


    > GetVal = Mid(A3, 1, 3) <--highlights A3 after error message


    GetVal = Mid([A3], 1, 3)


    Regards
    Claus Busch
    --
    Win XP PRof SP2 / Vista Ultimate SP2
    Office 2003 SP2 /2007 Ultimate SP2
     
    Claus Busch, Jun 7, 2012
    #2
    1. Advertisements

  3. Sub dural()
    GetVal = Mid(Range("A3").Value, 1, 3)
    MsgBox GetVal
    End Sub
     
    James Ravenswood, Jun 7, 2012
    #3
  4. bobh

    Don Guillett Guest

    On Thursday, June 7, 2012 8:37:54 AM UTC-5, bobh wrote:
    > I'm not an Excel vba person so I don't know why this doesn't work, any
    > help is appericated
    > I'm trying to get the first three characters of the value that's in
    > cell A3 and store it in the GetVal string variable. This keeps
    > erroring with the message 'Variable not defined' and it highlights the
    > A3 on the GetVal line
    >
    > Dim GetVal As String
    > Sheets("Dollars").Select
    > Range("A3").Select
    > GetVal = Mid(A3, 1, 3) <--highlights A3 after error message
    > If GetVal = "Oct" then
    > ...etc
    > end if
    >
    > thanks
    > bobh.

    You needed to use Range("a3") but
    ========
    if mid(Sheets("Dollars") _
    ..Range("A3"),1,3) ="Oct" then
    do this
    else
    do that
    end if

    or you could have used INSTR
     
    Don Guillett, Jun 7, 2012
    #4
  5. bobh

    bobh Guest

    On Jun 7, 9:37 am, bobh <> wrote:
    > I'm not an Excel vba person so I don't know why this doesn't work, any
    > help is appericated
    > I'm trying to get the first three characters of the value that's in
    > cell A3 and store it in the GetVal string variable. This keeps
    > erroring with the message 'Variable not defined' and it highlights the
    > A3 on the GetVal line
    >
    > Dim GetVal As String
    > Sheets("Dollars").Select
    > Range("A3").Select
    > GetVal = Mid(A3, 1, 3)  <--highlights A3 after error message
    > If GetVal = "Oct" then
    > ...etc
    > end if
    >
    > thanks
    > bobh.


    Thanks all...
    bobh.
     
    bobh, Jun 7, 2012
    #5
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. HGE

    MID Formula command

    HGE, Apr 7, 2005, in forum: Microsoft Excel Discussion
    Replies:
    4
    Views:
    189
    Guest
    Apr 7, 2005
  2. Charles Woll

    combining countif and mid or right functions

    Charles Woll, Jul 9, 2005, in forum: Microsoft Excel Discussion
    Replies:
    5
    Views:
    458
    Charles Woll
    Jul 10, 2005
  3. Ray K

    Using MID function within an IF funcion

    Ray K, Jun 8, 2006, in forum: Microsoft Excel Discussion
    Replies:
    0
    Views:
    196
    Ray K
    Jun 8, 2006
  4. Ray Kostanty

    Using MID function within an IF function

    Ray Kostanty, Jun 8, 2006, in forum: Microsoft Excel Discussion
    Replies:
    5
    Views:
    510
    Pete_UK
    Jun 9, 2006
  5. Rhaps

    Concatenate mid, left then right data

    Rhaps, Jan 10, 2007, in forum: Microsoft Excel Discussion
    Replies:
    4
    Views:
    467
    Ron Rosenfeld
    Jan 15, 2007
Loading...

Share This Page