Naming Ranges

  • Thread starter my.wandering.mind
  • Start date
M

my.wandering.mind

Hi All,

I have a some data in a sheet from which I copy selected rows into new
sheets when specific criteria is met.

Now I would like add names to ranges that are present in these new
sheets The number of rows copied vary. How can I write a vba code that
can capture this?

Ex (in sheet 1 i have data starting from b4 to w12. In this I want to
name a range which starts from M5 to W12....
In sheet 2 I have a data which starts from b4 to w45. in this sheet I
want to name a range which starts from M5 to W45)

Hope my explanation is clear..
Any Suggestions

Thanks for your help
vishnu
 
A

Arvi Laanemets

Hi

Use dynamic ranges, like
MyRange1=OFFSET(Sheet1!$M$4,1,,COUNTA(Sheet1!$B:$B)-1,10)
MyRange2=OFFSET(Sheet2!$M$4,1,,COUNTA(Sheet2!$B:$B)-1,10)

In this example the column B is a 'key column', where none of cells in
current datarange (with your data B4:B12 on Sheet1 and B4:B45 on Seet2) is
empty, and where all cells outside of current datarange are empty. When
there is not such column in your table, you have to create some helper
column where these conditions are met, and use this column in COUNTA part of
formula.
 

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

Top