ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Obtain last four characters from a cell. (https://www.excelbanter.com/excel-discussion-misc-queries/89027-obtain-last-four-characters-cell.html)

mohd21uk via OfficeKB.com

Obtain last four characters from a cell.
 
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

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200605/1

Bob Phillips

Obtain last four characters from a cell.
 
Range("A1").Value = Right(Range("A4").Value,4)

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"mohd21uk via OfficeKB.com" <u20517@uwe wrote in message
news:60615dea026f3@uwe...
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

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200605/1




mohd21uk via OfficeKB.com

Obtain last four characters from a cell.
 
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,

Bob Phillips wrote:
Range("A1").Value = Right(Range("A4").Value,4)

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


--
Message posted via http://www.officekb.com

Dave Peterson

Obtain last four characters from a cell.
 
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

"mohd21uk via OfficeKB.com" wrote:

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,

Bob Phillips wrote:
Range("A1").Value = Right(Range("A4").Value,4)

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


--
Message posted via http://www.officekb.com


--

Dave Peterson


All times are GMT +1. The time now is 09:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com