Find range within a range

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am currently calling a method written in a class in VB 6.0. This method of
the class is called on the form. The method takes a Range (i.e. Excel range
as a parameter). The method is not allowed to except more than this as a
parameter.

Now inside the range passed as a parameter there may or may not be a group
of cells (which themselves are part of a named range (this named range would
always start with letter TG_ but remaining part of the name is not known

I want the piece of code to be written inside this method in class so that
with the given range as parameter, I can scan it and find the cells which
belong to range starting with name as TG_

I am using VB 6.0 with Excel 2000.

Please do let me know if I can provide further inputs.

Thanks
 
You can use the .parent.parent of the range parameter to get a
reference to the workbook containing the range.
From there you should be able to figure out what named ranges exist
with names like TG_*.

Then try creating a range using intersect of the passed parameter and
the named range. If you get a result then that will represent the
cells in common to both the named range and the parameter range.


Tim.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top