Help with MID function

B

bobh

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.
 
C

Claus Busch

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
 
J

James Ravenswood

Sub dural()
GetVal = Mid(Range("A3").Value, 1, 3)
MsgBox GetVal
End Sub
 
D

Don Guillett

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
 
B

bobh

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top