PC Review


Reply
Thread Tools Rate Thread

Help with MID function

 
 
bobh
Guest
Posts: n/a
 
      7th Jun 2012
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.
 
Reply With Quote
 
 
 
 
Claus Busch
Guest
Posts: n/a
 
      7th Jun 2012
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
 
Reply With Quote
 
 
 
 
James Ravenswood
Guest
Posts: n/a
 
      7th Jun 2012
Sub dural()
GetVal = Mid(Range("A3").Value, 1, 3)
MsgBox GetVal
End Sub
 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      7th Jun 2012
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
 
Reply With Quote
 
bobh
Guest
Posts: n/a
 
      7th Jun 2012
On Jun 7, 9:37*am, bobh <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MID STATEMENT vs MID FUNCTION davidm Microsoft Excel Programming 5 28th Sep 2005 05:13 PM
Mid and Mid$ xl Microsoft Access VBA Modules 1 19th Jan 2004 05:02 PM
Re: right right$ left left$ mid mid$ Phobos Microsoft Excel Programming 1 29th Jul 2003 12:07 AM
Re: right right$ left left$ mid mid$ Bill Lunney Microsoft Excel Programming 0 21st Jul 2003 10:39 PM
Re: right right$ left left$ mid mid$ Charles Williams Microsoft Excel Programming 0 21st Jul 2003 09:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:40 AM.