Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Convert column data to trim all characters and leave the last 6

I'm trying to recall the vb syntax to perform the above function,
which will evaluate each row in a column that will have this type of
data:

3180015155 002075

and replace the current data with the last 6 characters like this:

002075

recommendations?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Convert column data to trim all characters and leave the last 6

Right, Left or Mid functions, depending on how your state them.

"S Himmelrich" wrote:

I'm trying to recall the vb syntax to perform the above function,
which will evaluate each row in a column that will have this type of
data:

3180015155 002075

and replace the current data with the last 6 characters like this:

002075

recommendations?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Convert column data to trim all characters and leave the last 6

Can you give me an example of the statement that I'd put in VB?

On Dec 6, 4:52 pm, JLGWhiz wrote:
Right, Left or Mid functions, depending on how your state them.

"S Himmelrich" wrote:
I'm trying to recall the vb syntax to perform the above function,
which will evaluate each row in a column that will have this type of
data:


3180015155 002075


and replace the current data with the last 6 characters like this:


002075


recommendations?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Convert column data to trim all characters and leave the last

3180015155 002075

and replace the current data with the last 6 characters like this:


002075



Assume the above data is in cell B2 of the ActiveSheet.

myVar = Right(Range("B2").Value, 6) 'myVar returns 002075
Or
myVar = Mid(Range("B2").Value, 12, 6) 'myVar returns 002075

There are more details available in the VBA help files by pressing Alt+F11
and typing [Right Function] or [Mid Function] in the Help search box, then
select the appropriate one from the menu that is displayed.



"S Himmelrich" wrote:

Can you give me an example of the statement that I'd put in VB?

On Dec 6, 4:52 pm, JLGWhiz wrote:
Right, Left or Mid functions, depending on how your state them.

"S Himmelrich" wrote:
I'm trying to recall the vb syntax to perform the above function,
which will evaluate each row in a column that will have this type of
data:


3180015155 002075


and replace the current data with the last 6 characters like this:


002075


recommendations?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Convert column data to trim all characters and leave the last

Here is what I've come up with:

' Convert account column
Columns("B:B").Select
Selection.Value = Right(Range("B2").Value, 6) 'myVar returns
002075

It doesn't work, it duplicates B2 for all cells with last six
characters...how to make it cycle through all records?







On Dec 6, 9:11 pm, JLGWhiz wrote:
3180015155 002075



and replace the current data with the last 6 characters like this:


002075


Assume the above data is in cell B2 of the ActiveSheet.

myVar =Right(Range("B2").Value, 6) 'myVar returns 002075
Or
myVar = Mid(Range("B2").Value, 12, 6) 'myVar returns 002075

There are more details available in the VBA help files by pressing Alt+F11
and typing [RightFunction] or [MidFunction] in the Help search box, then
select the appropriate one from the menu that is displayed.



"S Himmelrich" wrote:
Can you give me an example of the statement that I'd put in VB?


On Dec 6, 4:52 pm, JLGWhiz wrote:
Right, Left or Mid functions, depending on how your state them.


"S Himmelrich" wrote:
I'm trying to recall the vb syntax to perform the abovefunction,
which will evaluate each row in a column that will have this type of
data:


3180015155 002075


and replace the current data with the last 6 characters like this:


002075


recommendations?- Hide quoted text -


- Show quoted text -




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Convert column data to trim all characters and leave the last

On Dec 12, 8:40 pm, S Himmelrich wrote:
Here is what I've come up with:

' Convert account column
Columns("B:B").Select
Selection.Value = Right(Range("B2").Value, 6) 'myVar returns
002075

It doesn't work, it duplicates B2 for all cells with last six
characters...how to make it cycle through all records?

On Dec 6, 9:11 pm, JLGWhiz wrote:



3180015155 002075


and replace the current data with the last 6 characters like this:


002075


Assume the above data is in cell B2 of the ActiveSheet.


myVar =Right(Range("B2").Value, 6) 'myVar returns 002075
Or
myVar = Mid(Range("B2").Value, 12, 6) 'myVar returns 002075


There are more details available in the VBA help files by pressing Alt+F11
and typing [RightFunction] or [MidFunction] in the Help search box, then
select the appropriate one from the menu that is displayed.


"S Himmelrich" wrote:
Can you give me an example of the statement that I'd put in VB?


On Dec 6, 4:52 pm, JLGWhiz wrote:
Right, Left or Mid functions, depending on how your state them.


"S Himmelrich" wrote:
I'm trying to recall the vb syntax to perform the abovefunction,
which will evaluate each row in a column that will have this type of
data:


3180015155 002075


and replace the current data with the last 6 characters like this:


002075


recommendations?- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


Sub convert()

If ActiveCell.Value < 0 Then
Do Until ActiveCell.Value = ""
ActiveCell.Copy
ActiveCell.Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
Application.CutCopyMode = False
ActiveCell.Value = Right(ActiveCell, 6)
ActiveCell.Offset(1, -1).Select
Loop
End If
End Sub

This is what i understand from your text. Place the cursor on the
first value and run this code. It will copy the current value into
other cell and trim for the last six right digits. and carry on
working till the active cell is "" or empty.

Hope this will help........

Thanks,


AA
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
Trim out last seven characters from a string... DubboPete Excel Discussion (Misc queries) 3 February 2nd 10 05:16 AM
Trim characters Ronbo Excel Worksheet Functions 7 January 26th 09 09:29 PM
How do you trim characters? Tommi Excel Worksheet Functions 6 January 29th 06 01:38 PM
Trim the last two characters? Craig[_8_] Excel Programming 4 September 7th 04 02:52 AM
Trim characters Ange[_3_] Excel Programming 1 August 25th 04 07:31 PM


All times are GMT +1. The time now is 08:32 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"