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

Hi all, i have a string variable and i need to replace the first 12
places (Left side), which are 8 numeric (Variable) and 4 spaces,
(constant). Is it possible to do this and if so could you please help
with some code.

thanks in advance.

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Trim Variable

This is how I understand what you are asking, hope I have it right: You want
code that will "overwrite" the first 12 characters of your string, so these
characters will be erased and replaced with an 8 digit number that you have
in a different string variable and then 4 spaces. If that is it, then this
should do:
MyString = DigitString & " " & Right(MyString, Len(MyString)-12)
--
- K Dales


"Les Stout" wrote:

Hi all, i have a string variable and i need to replace the first 12
places (Left side), which are 8 numeric (Variable) and 4 spaces,
(constant). Is it possible to do this and if so could you please help
with some code.

thanks in advance.

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Trim Variable


sStr = "12345678 The Big Dog"
sStr = Right(sStr,len(sStr)-12)

demo'd from the immediate window:

sStr = "12345678 The Big Dog"
sStr = Right(sStr,len(sStr)-12)
? sStr
The Big Dog


--
Regards,
Tom Ogilvy

"Les Stout" wrote in message
...
Hi all, i have a string variable and i need to replace the first 12
places (Left side), which are 8 numeric (Variable) and 4 spaces,
(constant). Is it possible to do this and if so could you please help
with some code.

thanks in advance.

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Trim Variable

Thanks very much, Tom your result is what i was looking for.

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Trim Variable

Sub Replace()
Dim sVar As String
Dim WhatEver As String

sVar = Right(sVar, Len(sVar) - 12)
WhatEver = "whatevruwant"
sVar = WhatEver & sVar
End Sub

Mike F
"Les Stout" wrote in message
...
Hi all, i have a string variable and i need to replace the first 12
places (Left side), which are 8 numeric (Variable) and 4 spaces,
(constant). Is it possible to do this and if so could you please help
with some code.

thanks in advance.

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***





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 Chey Excel Discussion (Misc queries) 4 July 16th 07 07:58 PM
VBA and Trim Jake[_10_] Excel Programming 1 January 25th 05 07:01 PM
VBA Trim and Application.worksheetfunction.Trim Hari Prasadh Excel Programming 3 January 19th 05 02:22 PM
Trim in VBA Otto Moehrbach[_6_] Excel Programming 4 May 18th 04 05:23 PM
Trim like worksheet Trim Bob Phillips[_5_] Excel Programming 0 August 20th 03 07:10 PM


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