creating a subrange 
Author Message
 creating a subrange

I have what's probably a simple question:

I have a variable (type:range, variable is called: "Word") that stores one word.

How do I assign just the last character of that word to a new variable (lastChar)
of type range?

I can't seem to get a range object from a range. I.e., Word.range doesn't work.

TIA.

Todd



Fri, 19 Sep 2003 20:56:13 GMT  
 creating a subrange
Hi Todd,

Quote:
> I have what's probably a simple question:

Simple question, complex answer ;-)

Quote:
> I have a variable (type:range, variable is called: "Word") that
> stores one word.

Just a comment here. It is a bad idea to name your variables with reserved
words. Call it "oWord" or somesuch.

Quote:
> How do I assign just the last character of that word to a new
> variable (lastChar) of type range?

So you want to set a Range to the last character in an existing Range. Try
this:

---------------------------------------------------

Dim oWord As Range
Dim lastChar As Range

Set oWord = Selection.Range

Set lastChar = oWord.Characters.Last

lastChar.Select

---------------------------------------------------

Here it is important to note that the Character object is actually a Range.
It is also important to note that ifyou are using the Words collection to
set the the Range oWord, any trailing spaces are considered part of the
word.

--
Hope this helps.
ibby

Please post replies or follow-ups to the **newsgroup** so that participants
may benefit or contribute.



Fri, 19 Sep 2003 21:53:43 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Subtotals on subrange.

2. Subtotals on subrange.

3. Create a routine that creates html for every query

4. SQL Create table vs Creating TableDef Object in VBA

5. How to create method that create an object

6. Creating a Macro to create simple numbers

7. How to create Event on dynamicaly created controls?

8. create table query creates strange fields

9. Creating App for user to create Forms and Controls with VB

10. How to create a icon when create a .exe file

11. Create a control object without creating a control?

12. DATE CREATED and FILE TIME CREATED

 

 
Powered by phpBB® Forum Software