LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Removing last 2 digits on a number in Excel

I have the following VBA macro so that on a 12 digit number in column A
on my spreadsheets, it keeps only the first 10 digits in the same cell.


What I want to do is change it so that it doesn't assume my data will
always be in column A, but whatever column I have highlighted. So if I
were to highlight all of Column C, it would perform the function all
the way down the column.

Dim rng As Range
For Each rng In Columns(1).SpecialCells(xlConstants, xlNumbers).Areas
rng.TextToColumns _
Destination:=rng, _
DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(2, 9))
Next

Also, once in a while, the data I have will only have 11 digits in
which case I would want to remove the last 2 digits and add a zero to
the front of the remaining number keeping it at 10 digits total again.
Is there a way to accomplish this task in the same script?

Example of numbers I will have in the spreadsheet:

127647794701
97124764905

Number one I want to be: 1276477947
Number two I want to be: 0971247649

Thanks for any suggestions.....

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA write macro change column with 3 number digits to 4 digits the James C[_2_] Excel Discussion (Misc queries) 3 January 25th 10 03:12 PM
Removing Digits Faraz A. Qureshi Excel Discussion (Misc queries) 3 October 27th 09 02:09 PM
How to customize number to 10 digits including 2 digits after deci Carina Excel Worksheet Functions 3 September 20th 07 02:50 AM
Removing the last two digits of a cell kestrel Excel Worksheet Functions 3 May 17th 06 10:41 PM
help with removing digits from a number frank Excel Discussion (Misc queries) 4 July 12th 05 02:31 AM


All times are GMT +1. The time now is 11:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"