Excel - Help with MID function

Asked By bobh on 07-Jun-12 09:37 AM
I am not an Excel vba person so I do not know why this does not work, any
help is appericated
I am trying to get the first three characters of the value that is 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.


Claus Busch replied to bobh on 07-Jun-12 09:57 AM
Hi Bob,

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



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


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
James Ravenswood replied to bobh on 07-Jun-12 10:03 AM
Sub dural()
GetVal = Mid(Range("A3").Value, 1, 3)
MsgBox GetVal
End Sub
Don Guillett replied to bobh on 07-Jun-12 10:03 AM
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
bobh replied to bobh on 07-Jun-12 01:11 PM
Thanks all...
bobh.