Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Trim Function

how can i trim these values in a loop?

551569206 024201036
249721825 019
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Trim Function

Let me be more clear.
The first set of digets will always be 9 char long and the next set of
digits will start at char 16. Id like to loop thru the column and trim the
spaces in the middle

Row1 551569206 024201036
Row2 249721825 019
Row3 249877803 018012
Row4 249877803 018012012236

"Mike" wrote:

how can i trim these values in a loop?

551569206 024201036
249721825 019

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Trim Function

Nevermind I was having a Brain Freeze. Heres what I have used.
cell.Offset(0, 6).Value = Replace(cell.Offset(0, 6).Value, " ", "")

"Mike" wrote:

Let me be more clear.
The first set of digets will always be 9 char long and the next set of
digits will start at char 16. Id like to loop thru the column and trim the
spaces in the middle

Row1 551569206 024201036
Row2 249721825 019
Row3 249877803 018012
Row4 249877803 018012012236

"Mike" wrote:

how can i trim these values in a loop?

551569206 024201036
249721825 019

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Trim Function

When you get to my age, you just assume those mental lapses. <g

"Mike" wrote:

Nevermind I was having a Brain Freeze. Heres what I have used.
cell.Offset(0, 6).Value = Replace(cell.Offset(0, 6).Value, " ", "")

"Mike" wrote:

Let me be more clear.
The first set of digets will always be 9 char long and the next set of
digits will start at char 16. Id like to loop thru the column and trim the
spaces in the middle

Row1 551569206 024201036
Row2 249721825 019
Row3 249877803 018012
Row4 249877803 018012012236

"Mike" wrote:

how can i trim these values in a loop?

551569206 024201036
249721825 019

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Trim Function

or maybe...

with cell.Offset(0, 6)
.Value = trim(.Value)
end with

or

with cell.Offset(0, 6)
.Value = application.trim(.Value)
end with

The difference between VBA's Trim and excel's =trim() is how they treat
consecutive internal spaces. VBA's Trim will leave them as-is. Excel's =trim()
will "trim" them to a single character.




Mike wrote:

Nevermind I was having a Brain Freeze. Heres what I have used.
cell.Offset(0, 6).Value = Replace(cell.Offset(0, 6).Value, " ", "")

"Mike" wrote:

Let me be more clear.
The first set of digets will always be 9 char long and the next set of
digits will start at char 16. Id like to loop thru the column and trim the
spaces in the middle

Row1 551569206 024201036
Row2 249721825 019
Row3 249877803 018012
Row4 249877803 018012012236

"Mike" wrote:

how can i trim these values in a loop?

551569206 024201036
249721825 019


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Trim Function

Thanks Dave but this wouldn't work for me. I was trying that before I posted
my question. Thanks anyway.

"Dave Peterson" wrote:

or maybe...

with cell.Offset(0, 6)
.Value = trim(.Value)
end with

or

with cell.Offset(0, 6)
.Value = application.trim(.Value)
end with

The difference between VBA's Trim and excel's =trim() is how they treat
consecutive internal spaces. VBA's Trim will leave them as-is. Excel's =trim()
will "trim" them to a single character.




Mike wrote:

Nevermind I was having a Brain Freeze. Heres what I have used.
cell.Offset(0, 6).Value = Replace(cell.Offset(0, 6).Value, " ", "")

"Mike" wrote:

Let me be more clear.
The first set of digets will always be 9 char long and the next set of
digits will start at char 16. Id like to loop thru the column and trim the
spaces in the middle

Row1 551569206 024201036
Row2 249721825 019
Row3 249877803 018012
Row4 249877803 018012012236

"Mike" wrote:

how can i trim these values in a loop?

551569206 024201036
249721825 019


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Trim Function

And this was leaving a 1 space ?? Who knows.
with cell.Offset(0, 6)
..Value = application.trim(.Value)
end with

But this worked
with cell.Offset(0, 6)
Value = Replace(.Value, " ", "")
end with
"Dave Peterson" wrote:

or maybe...

with cell.Offset(0, 6)
.Value = trim(.Value)
end with

or

with cell.Offset(0, 6)
.Value = application.trim(.Value)
end with

The difference between VBA's Trim and excel's =trim() is how they treat
consecutive internal spaces. VBA's Trim will leave them as-is. Excel's =trim()
will "trim" them to a single character.




Mike wrote:

Nevermind I was having a Brain Freeze. Heres what I have used.
cell.Offset(0, 6).Value = Replace(cell.Offset(0, 6).Value, " ", "")

"Mike" wrote:

Let me be more clear.
The first set of digets will always be 9 char long and the next set of
digits will start at char 16. Id like to loop thru the column and trim the
spaces in the middle

Row1 551569206 024201036
Row2 249721825 019
Row3 249877803 018012
Row4 249877803 018012012236

"Mike" wrote:

how can i trim these values in a loop?

551569206 024201036
249721825 019


--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Trim Function

Ahhh.

I just reread one of your messasges. I thought that this:

551569206 024201036
249721825 019

Represented 4 different cells. Not 2 cells with embedded spaces.

I'd use the same thing you used to remove those internal spaces--as long as any
of those strings of digits would be longer than 15 digits.

(Fewer than 16 digits and you could select the range and do an edit|Replace to
remove the space character.)

Mike wrote:

And this was leaving a 1 space ?? Who knows.
with cell.Offset(0, 6)
.Value = application.trim(.Value)
end with

But this worked
with cell.Offset(0, 6)
Value = Replace(.Value, " ", "")
end with
"Dave Peterson" wrote:

or maybe...

with cell.Offset(0, 6)
.Value = trim(.Value)
end with

or

with cell.Offset(0, 6)
.Value = application.trim(.Value)
end with

The difference between VBA's Trim and excel's =trim() is how they treat
consecutive internal spaces. VBA's Trim will leave them as-is. Excel's =trim()
will "trim" them to a single character.




Mike wrote:

Nevermind I was having a Brain Freeze. Heres what I have used.
cell.Offset(0, 6).Value = Replace(cell.Offset(0, 6).Value, " ", "")

"Mike" wrote:

Let me be more clear.
The first set of digets will always be 9 char long and the next set of
digits will start at char 16. Id like to loop thru the column and trim the
spaces in the middle

Row1 551569206 024201036
Row2 249721825 019
Row3 249877803 018012
Row4 249877803 018012012236

"Mike" wrote:

how can i trim these values in a loop?

551569206 024201036
249721825 019


--

Dave Peterson


--

Dave Peterson
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
Len & Trim Function Daren Excel Worksheet Functions 6 October 14th 08 02:32 PM
TRIM FUNCTION...how to? Shayra Excel Worksheet Functions 3 March 10th 08 06:39 PM
Trim Function Saxman[_2_] Excel Discussion (Misc queries) 7 August 2nd 07 01:20 AM
Trim Function Matt M HMS Excel Worksheet Functions 5 November 21st 05 10:46 PM
Help with TRIM Function Willie T Excel Programming 3 January 8th 05 02:43 AM


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