Obtain last four characters from a cell.

  • Thread starter mohd21uk via OfficeKB.com
  • Start date
M

mohd21uk via OfficeKB.com

I am using a macro to validate a form. I would like cell A1 to equate to the
last four charecters of cell a4. For e.g if cell a1 is 552004k00 cell a4
should have the value 4k00. I would be grateful if you could provide this to
me in VBA code.

Thanks
 
B

Bob Phillips

Range("A1").Value = Right(Range("A4").Value,4)

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)
 
M

mohd21uk via OfficeKB.com

I have tried this function but it still gives me errors. I get the E+15 error.
I am wondering how I can change this,
 
D

Dave Peterson

I think it'll depend on what's in those last 4 characters.

with Range("A1")
.numberformat = "@" 'make it text
.Value = Right(Range("A4").Text,4)
end with
 

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