Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 718
Default Macro for Removing Characters

Hello,

I was wondering if there's a way to make a macro or sub that will remove the
last four characters of the value that is in the cells I select?

I tried to record a macro but when I looked at it in the editor all it did
was have the below...

Range("G4").Select
ActiveCell.FormulaR1C1 = "Test Remove Value "

The value used to read "Test Remove Value Text"


The issue is that the value is a series of random whatever and I want to be
able to select a bunch of cells all at once and then have it remove just the
last four characters.


Thanks Very Much In Advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro for Removing Characters

This should do what you want...

Sub RemoveLast4Characters()
Dim C As Range
For Each C In Selection
C.Value = Left(C.Value, Len(C.Value) - 4)
Next
End Sub

Rick


"Rob" wrote in message
...
Hello,

I was wondering if there's a way to make a macro or sub that will remove
the
last four characters of the value that is in the cells I select?

I tried to record a macro but when I looked at it in the editor all it did
was have the below...

Range("G4").Select
ActiveCell.FormulaR1C1 = "Test Remove Value "

The value used to read "Test Remove Value Text"


The issue is that the value is a series of random whatever and I want to
be
able to select a bunch of cells all at once and then have it remove just
the
last four characters.


Thanks Very Much In Advance.


  #4   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 718
Default Macro for Removing Characters

OMGoodness! That worked perfectly! Thank you so much.

Mind if I ask how long it took to learn how to do this kind of stuff? It's
so hard for me to get a grasp on it, so much so that everytime I try I just
cannot seem to pick it up.

Thanks Again!


"Rick Rothstein (MVP - VB)" wrote:

This should do what you want...

Sub RemoveLast4Characters()
Dim C As Range
For Each C In Selection
C.Value = Left(C.Value, Len(C.Value) - 4)
Next
End Sub

Rick


"Rob" wrote in message
...
Hello,

I was wondering if there's a way to make a macro or sub that will remove
the
last four characters of the value that is in the cells I select?

I tried to record a macro but when I looked at it in the editor all it did
was have the below...

Range("G4").Select
ActiveCell.FormulaR1C1 = "Test Remove Value "

The value used to read "Test Remove Value Text"


The issue is that the value is a series of random whatever and I want to
be
able to select a bunch of cells all at once and then have it remove just
the
last four characters.


Thanks Very Much In Advance.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro for Removing Characters

That is a hard question to answer. I have been programming in various
languages since 1981 and I still manage to learn new things from others by
reading the various postings on these newsgroups. I don't mean that to be
discouraging by any means; I just want to point out that you can never know
it all. However, you should try to learn the basics, and the syntax for it,
of whatever language you are learning (VBA in your case I would guess). That
means, variable declaration (that being the various data types available),
variable assignments, loops (For-Next, Do-Loop) and branching (If-Then,
Select Case)... these are common to all languages, but can be implemented
differently in each. Next, you should familiarize yourself with the various
functions and statements the language offers (usually there is a Reference
section in the help files to aid you in this). Note I said familiarize, not
memorize; eventually you will memorize the key components you use over and
over again, but it is important to "know" that you have seen a function or
statement that does something similar to what you are thinking you want to
do... you can always look up the syntax later, but if you know it exists, it
will become part of your "code thinking" process as you develop your
programs; and, conversely, if you do not "know" there is a function or
statement that does something similar to what you want, you will miss that
avenue of approach (obviously, since it can't occur to you to consider it)
when developing your solution. After that, familiarize yourself with
"scope"... this has to do with where your variables, subroutines and
functions can be seen (where you declare them determines how much exposure
they have). That will get you started, but the most important way to learn a
language is to practice, practice, practice. And don't be afraid of
mistakes... the more you make, the more you learn. I'm serious when I say
that. Develop some code that you think should work, and when it fails to
work correctly, the process of debugging (correcting the mistakes) will show
you where your original thinking was wrong and this process tends to be
remembered afterwards... you will not tend to make the same mistakes over
and over and over again (maybe once, twice or even three times, but after
awhile, you will learn how to correctly handle the situation).

Rick


"Rob" wrote in message
...
OMGoodness! That worked perfectly! Thank you so much.

Mind if I ask how long it took to learn how to do this kind of stuff?
It's
so hard for me to get a grasp on it, so much so that everytime I try I
just
cannot seem to pick it up.

Thanks Again!


"Rick Rothstein (MVP - VB)" wrote:

This should do what you want...

Sub RemoveLast4Characters()
Dim C As Range
For Each C In Selection
C.Value = Left(C.Value, Len(C.Value) - 4)
Next
End Sub

Rick


"Rob" wrote in message
...
Hello,

I was wondering if there's a way to make a macro or sub that will
remove
the
last four characters of the value that is in the cells I select?

I tried to record a macro but when I looked at it in the editor all it
did
was have the below...

Range("G4").Select
ActiveCell.FormulaR1C1 = "Test Remove Value "

The value used to read "Test Remove Value Text"


The issue is that the value is a series of random whatever and I want
to
be
able to select a bunch of cells all at once and then have it remove
just
the
last four characters.


Thanks Very Much In Advance.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Macro for Removing Characters

Your comments are one of the best short-advice-clips I have read! Thanks
(Copy/Paste/Save)

EagleOne

"Rick Rothstein \(MVP - VB\)" wrote:

That is a hard question to answer. I have been programming in various
languages since 1981 and I still manage to learn new things from others by
reading the various postings on these newsgroups. I don't mean that to be
discouraging by any means; I just want to point out that you can never know
it all. However, you should try to learn the basics, and the syntax for it,
of whatever language you are learning (VBA in your case I would guess). That
means, variable declaration (that being the various data types available),
variable assignments, loops (For-Next, Do-Loop) and branching (If-Then,
Select Case)... these are common to all languages, but can be implemented
differently in each. Next, you should familiarize yourself with the various
functions and statements the language offers (usually there is a Reference
section in the help files to aid you in this). Note I said familiarize, not
memorize; eventually you will memorize the key components you use over and
over again, but it is important to "know" that you have seen a function or
statement that does something similar to what you are thinking you want to
do... you can always look up the syntax later, but if you know it exists, it
will become part of your "code thinking" process as you develop your
programs; and, conversely, if you do not "know" there is a function or
statement that does something similar to what you want, you will miss that
avenue of approach (obviously, since it can't occur to you to consider it)
when developing your solution. After that, familiarize yourself with
"scope"... this has to do with where your variables, subroutines and
functions can be seen (where you declare them determines how much exposure
they have). That will get you started, but the most important way to learn a
language is to practice, practice, practice. And don't be afraid of
mistakes... the more you make, the more you learn. I'm serious when I say
that. Develop some code that you think should work, and when it fails to
work correctly, the process of debugging (correcting the mistakes) will show
you where your original thinking was wrong and this process tends to be
remembered afterwards... you will not tend to make the same mistakes over
and over and over again (maybe once, twice or even three times, but after
awhile, you will learn how to correctly handle the situation).

Rick


"Rob" wrote in message
...
OMGoodness! That worked perfectly! Thank you so much.

Mind if I ask how long it took to learn how to do this kind of stuff?
It's
so hard for me to get a grasp on it, so much so that everytime I try I
just
cannot seem to pick it up.

Thanks Again!


"Rick Rothstein (MVP - VB)" wrote:

This should do what you want...

Sub RemoveLast4Characters()
Dim C As Range
For Each C In Selection
C.Value = Left(C.Value, Len(C.Value) - 4)
Next
End Sub

Rick


"Rob" wrote in message
...
Hello,

I was wondering if there's a way to make a macro or sub that will
remove
the
last four characters of the value that is in the cells I select?

I tried to record a macro but when I looked at it in the editor all it
did
was have the below...

Range("G4").Select
ActiveCell.FormulaR1C1 = "Test Remove Value "

The value used to read "Test Remove Value Text"


The issue is that the value is a series of random whatever and I want
to
be
able to select a bunch of cells all at once and then have it remove
just
the
last four characters.


Thanks Very Much In Advance.



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
Removing 2-3 characters at the end Ty Excel Worksheet Functions 7 June 11th 11 01:41 AM
removing characters DEI[_2_] Excel Discussion (Misc queries) 7 April 29th 08 09:02 PM
Removing characters Maksko Excel Discussion (Misc queries) 8 November 3rd 06 11:26 AM
Removing characters Tomsriv Excel Worksheet Functions 2 August 14th 06 11:54 PM
Removing characters asmenut Excel Programming 2 August 14th 05 02:46 PM


All times are GMT +1. The time now is 05:55 AM.

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"