Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Finding last number in cell

Here is my situation. I hav a macro that inputs into excel all the file names in a directory and I get results like this in coulmn A. There will not always be the same number of files, it changes each tim

:\ab123
:\df113
:\gh234

My problem comes in editing the list - I need to first remove all of the ":\" from each cell (file name), and then I need to get the last value in the name to sort the files, in this case it would be





and I would want to but those values in column B

I am currently searching through google but any help would be greatly appreciated

Jim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Finding last number in cell

Hi James,

You can use the Replace$() function to remove the :\ from each cell:

Cells(n, 1).Value=Replace$(Cells(n, 1).Value, ":\", "")

And you can use the Right$() function to get the last number:

Cells(n, 2).Value=Right$(Cells(n, 1).Value, 1)

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


James Stephens wrote:
Here is my situation. I hav a macro that inputs into excel all the
file names in a directory and I get results like this in coulmn A.
There will not always be the same number of files, it changes each
time

:\ab1234
:\df1133
:\gh2345

My problem comes in editing the list - I need to first remove all of
the ":\" from each cell (file name), and then I need to get the last
value in the name to sort the files, in this case it would be

4
3
5

and I would want to but those values in column B.

I am currently searching through google but any help would be greatly
appreciated.

Jim

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Finding last number in cell

Thanks, worked great, and works to solve some other code issues too.

Thanks again,

Jim

----- Jake Marx wrote: -----

Hi James,

You can use the Replace$() function to remove the :\ from each cell:

Cells(n, 1).Value=Replace$(Cells(n, 1).Value, ":\", "")

And you can use the Right$() function to get the last number:

Cells(n, 2).Value=Right$(Cells(n, 1).Value, 1)

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


James Stephens wrote:
Here is my situation. I hav a macro that inputs into excel all the
file names in a directory and I get results like this in coulmn A.
There will not always be the same number of files, it changes each
time
:\ab1234

:\df1133
:\gh2345
My problem comes in editing the list - I need to first remove all of

the ":\" from each cell (file name), and then I need to get the last
value in the name to sort the files, in this case it would be
4

3
5
and I would want to but those values in column B.
I am currently searching through google but any help would be greatly

appreciated.
Jim


Reply
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
Finding Number Inside a Cell pallaver Excel Discussion (Misc queries) 14 July 16th 08 01:35 AM
Finding Cell that changes from a Positive to a Negitive number tpeter Excel Worksheet Functions 2 December 12th 07 06:27 PM
Sum x number of right cells after finding first cell more than 0. Learn Excel Worksheet Functions 4 December 9th 07 04:57 PM
Finding the Row number based on contents of a cell Chris Youlden Excel Worksheet Functions 5 September 6th 07 04:38 PM
finding a particular cell in another worksheet whose row number ch Andrew Excel Discussion (Misc queries) 1 September 12th 05 01:36 PM


All times are GMT +1. The time now is 07:34 PM.

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

About Us

"It's about Microsoft Excel"