PC Review


Reply
Thread Tools Rate Thread

Convert column data to trim all characters and leave the last 6

 
 
S Himmelrich
Guest
Posts: n/a
 
      6th Dec 2007
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?
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      6th Dec 2007
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?
>

 
Reply With Quote
 
S Himmelrich
Guest
Posts: n/a
 
      6th Dec 2007
Can you give me an example of the statement that I'd put in VB?

On Dec 6, 4:52 pm, JLGWhiz <JLGW...@discussions.microsoft.com> 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?


 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      7th Dec 2007
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 <JLGW...@discussions.microsoft.com> 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?

>
>

 
Reply With Quote
 
S Himmelrich
Guest
Posts: n/a
 
      12th Dec 2007
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 <JLGW...@discussions.microsoft.com> 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 <JLGW...@discussions.microsoft.com> 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 -


 
Reply With Quote
 
Abi
Guest
Posts: n/a
 
      14th Dec 2007
On Dec 12, 8:40 pm, S Himmelrich <himmelr...@gmail.com> 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 <JLGW...@discussions.microsoft.com> 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 <JLGW...@discussions.microsoft.com> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
trim first letter to leave number Billp Microsoft Access Queries 4 29th Jul 2009 07:23 AM
Need macro to trim characters in column TonyV Microsoft Excel Programming 5 10th Jan 2008 04:51 PM
Convert data to consistent number of characters =?Utf-8?B?RGF2ZSBTY2hvZW5icnVu?= Microsoft Access VBA Modules 2 9th May 2007 04:41 PM
How do you trim characters? Tommi Microsoft Excel Worksheet Functions 6 29th Jan 2006 01:38 PM
Trim characters Ange Microsoft Excel Programming 1 25th Aug 2004 07:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:41 AM.