Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Help with Range Probelm PLEASE !

Ok here is my problem I am using the DirectPrecedents method to return an
address sometimes that address will be one cell sometimes it will be a range
of cells. What I was Going to do is have the address(String) returned by the
DirectPrecedents (ie.. "$C$5:$C$10") Parsed using some other code so that I
could chop out the row values from the string (ie 5 and 10) and than convert
them to integers, subtract them from each other and if the difference is
greater than 0 that would let me know if the DirectPrecedents for the cell
selected has one or more than one Precedents linked to it.




Dim CurrentCel
Dim X

With ActiveSheet
CurrentCel = ActiveCell.Address
X = .Range(CurrentCel).DirectPrecedents.Address
'This is the part I need to some how say If the range of X is more than
'one cell than (Run this code) else (Run that code)
I was going to put somthing like this
Z=0
For each cel in X
Z = Z + 1
next
but I cant do that because VBA doesn't see X as Range only as string.
this would be much simpler than using a string parsing code and converting
the values in the string to Integers just to preform some math so vba can
tell me if the range returned in string form form the DirectPrecedents method
is greater than one cel.

Help Please there has to be an easyer way ?

Dan Thompson


End With
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Help with Range Probelm PLEASE !

You are making it too hard.
DirectPrecedents returns a range object. So...
'--
Dim X as Range
Dim Z as Long
Set X = Range(CurrentCel).DirectPrecedents
Z = X.Cells.Count
'--
Jim Cone
Portland, Oregon USA


"Dan Thompson"

wrote in message
Ok here is my problem I am using the DirectPrecedents method to return an
address sometimes that address will be one cell sometimes it will be a range
of cells. What I was Going to do is have the address(String) returned by the
DirectPrecedents (ie.. "$C$5:$C$10") Parsed using some other code so that I
could chop out the row values from the string (ie 5 and 10) and than convert
them to integers, subtract them from each other and if the difference is
greater than 0 that would let me know if the DirectPrecedents for the cell
selected has one or more than one Precedents linked to it.




Dim CurrentCel
Dim X

With ActiveSheet
CurrentCel = ActiveCell.Address
X = .Range(CurrentCel).DirectPrecedents.Address
'This is the part I need to some how say If the range of X is more than
'one cell than (Run this code) else (Run that code)
I was going to put somthing like this
Z=0
For each cel in X
Z = Z + 1
next
but I can't do that because VBA doesn't see X as Range only as string.
this would be much simpler than using a string parsing code and converting
the values in the string to Integers just to preform some math so vba can
tell me if the range returned in string form form the DirectPrecedents method
is greater than one cel.
End With
Help Please there has to be an easyer way ?
Dan Thompson


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Help with Range Probelm PLEASE !

Further...
There is code of mine to return precedents/dependents
in this post from January...
http://tinyurl.com/celfut
--
Jim Cone
Portland, Oregon USA

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Help with Range Probelm PLEASE !

Thanks Jim your advice was of great help to me and much simpler too.
I new there was an easier way. I was having trouble finding information
yesterday on what different methods in vba will return is there a simple list
in the help file that will say this method will return these objects ect..

Again thanks for your help Jim
You ROCK !

"Jim Cone" wrote:

You are making it too hard.
DirectPrecedents returns a range object. So...
'--
Dim X as Range
Dim Z as Long
Set X = Range(CurrentCel).DirectPrecedents
Z = X.Cells.Count
'--
Jim Cone
Portland, Oregon USA


"Dan Thompson"

wrote in message
Ok here is my problem I am using the DirectPrecedents method to return an
address sometimes that address will be one cell sometimes it will be a range
of cells. What I was Going to do is have the address(String) returned by the
DirectPrecedents (ie.. "$C$5:$C$10") Parsed using some other code so that I
could chop out the row values from the string (ie 5 and 10) and than convert
them to integers, subtract them from each other and if the difference is
greater than 0 that would let me know if the DirectPrecedents for the cell
selected has one or more than one Precedents linked to it.




Dim CurrentCel
Dim X

With ActiveSheet
CurrentCel = ActiveCell.Address
X = .Range(CurrentCel).DirectPrecedents.Address
'This is the part I need to some how say If the range of X is more than
'one cell than (Run this code) else (Run that code)
I was going to put somthing like this
Z=0
For each cel in X
Z = Z + 1
next
but I can't do that because VBA doesn't see X as Range only as string.
this would be much simpler than using a string parsing code and converting
the values in the string to Integers just to preform some math so vba can
tell me if the range returned in string form form the DirectPrecedents method
is greater than one cel.
End With
Help Please there has to be an easyer way ?
Dan Thompson



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Help with Range Probelm PLEASE !

You are welcome.
As for a "simple list" in the help file, the answer is no.
In the case of "DirectPrecedents", the help file states that it returns
a range object.
Looking up "Range" then gives you the long list of properties and
methods that apply to a range.
Range properties and methods are the ones to become very familiar with.
(maybe make your own list)

Note that Range has a count property, but I used X.Cells.Count not
X.Count. The range returned could have consisted of entire columns
or entire rows and the X.Count property, in those cases, would have
returned the columns count or rows count (not the count of cells).
--
Jim Cone
Portland, Oregon USA




"Dan Thompson"

wrote in message
Thanks Jim your advice was of great help to me and much simpler too.
I new there was an easier way. I was having trouble finding information
yesterday on what different methods in vba will return is there a simple list
in the help file that will say this method will return these objects ect..

Again thanks for your help Jim
You ROCK !

"Jim Cone" wrote:

You are making it too hard.
DirectPrecedents returns a range object. So...
'--
Dim X as Range
Dim Z as Long
Set X = Range(CurrentCel).DirectPrecedents
Z = X.Cells.Count
'--
Jim Cone
Portland, Oregon USA


"Dan Thompson"

wrote in message
Ok here is my problem I am using the DirectPrecedents method to return an
address sometimes that address will be one cell sometimes it will be a range
of cells. What I was Going to do is have the address(String) returned by the
DirectPrecedents (ie.. "$C$5:$C$10") Parsed using some other code so that I
could chop out the row values from the string (ie 5 and 10) and than convert
them to integers, subtract them from each other and if the difference is
greater than 0 that would let me know if the DirectPrecedents for the cell
selected has one or more than one Precedents linked to it.




Dim CurrentCel
Dim X

With ActiveSheet
CurrentCel = ActiveCell.Address
X = .Range(CurrentCel).DirectPrecedents.Address
'This is the part I need to some how say If the range of X is more than
'one cell than (Run this code) else (Run that code)
I was going to put somthing like this
Z=0
For each cel in X
Z = Z + 1
next
but I can't do that because VBA doesn't see X as Range only as string.
this would be much simpler than using a string parsing code and converting
the values in the string to Integers just to preform some math so vba can
tell me if the range returned in string form form the DirectPrecedents method
is greater than one cel.
End With
Help Please there has to be an easyer way ?
Dan Thompson





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
Probelm with macro mac Excel Worksheet Functions 5 January 14th 08 07:47 PM
Vlookup probelm NewToVB Excel Programming 2 July 25th 07 03:34 PM
Hyperlink probelm Glenn Richardson Excel Worksheet Functions 2 August 30th 05 02:26 PM
Hyperlink probelm Glenn Richardson Excel Discussion (Misc queries) 1 August 30th 05 01:44 PM
Range probelm in VB6 K.K.[_2_] Excel Programming 4 July 1st 04 12:07 PM


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