Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
montgomerymouse
 
Posts: n/a
Default Problem Working with Named Ranges

Hi,

On one worksheet in my workbook, I have an outline with expandable and
collapsable rows (using the group function). In another worksheet, I have
different buttons which runs different macros that will link me to the
sections of the outline that I want expanded (while the rest remains
collapsed).

I was able to get a macro to work using absolute values for a cell position,
but I have been unsuccesful trying to work with name ranges. This is a
problem, as I frequently add new rows to the outline so I'm constantly having
to update the macro.

Can someone help me put relative values in the macro so that it will adjust
as I add new rows?

I think the best way to tackle this might be to use named ranges.

Here's the script that worked with absolute values:

Sub SQ5()

Sheets("Horizontal").Select
Rows(2).ShowDetail = True
Rows(96).ShowDetail = True
Rows(97).ShowDetail = True

End Sub


Here's what I wrote that is *not* working with ranges.


Sub SQ5()

Sheets("Horizontal").Select

Rows(2).ShowDetail = True
Range("IIA").ShowDetail = True
Range("SV").ShowDetail = True

End Sub

FYI, I'm fairly new to macros. Thank you in advance for whatever help you
can provide!

  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

I'm not sure what the names IIA and SA refer to, but maybe...

Sub SQ5()
Sheets("Horizontal").Select
Rows(2).ShowDetail = True
Range("IIA").entirerow.ShowDetail = True
Range("SV").entirerow.ShowDetail = True
End Sub

And you can do things without selecting the worksheet:

Sub SQ5a()
With Worksheets("Horizontal")
.Rows(2).ShowDetail = True
.Range("IIA").EntireRow.ShowDetail = True
.Range("SV").EntireRow.ShowDetail = True
End With
End Sub

I think it makes it a little easier to read when you're trying to fix it later
on!

montgomerymouse wrote:

Hi,

On one worksheet in my workbook, I have an outline with expandable and
collapsable rows (using the group function). In another worksheet, I have
different buttons which runs different macros that will link me to the
sections of the outline that I want expanded (while the rest remains
collapsed).

I was able to get a macro to work using absolute values for a cell position,
but I have been unsuccesful trying to work with name ranges. This is a
problem, as I frequently add new rows to the outline so I'm constantly having
to update the macro.

Can someone help me put relative values in the macro so that it will adjust
as I add new rows?

I think the best way to tackle this might be to use named ranges.

Here's the script that worked with absolute values:

Sub SQ5()

Sheets("Horizontal").Select
Rows(2).ShowDetail = True
Rows(96).ShowDetail = True
Rows(97).ShowDetail = True

End Sub

Here's what I wrote that is *not* working with ranges.

Sub SQ5()

Sheets("Horizontal").Select

Rows(2).ShowDetail = True
Range("IIA").ShowDetail = True
Range("SV").ShowDetail = True

End Sub

FYI, I'm fairly new to macros. Thank you in advance for whatever help you
can provide!


--

Dave Peterson
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
How to Link named ranges from multiple Workbooks into a single Wo. PMAP_HELP Excel Discussion (Misc queries) 1 December 14th 04 05:51 PM
Named Cell Ranges Blackcat Excel Discussion (Misc queries) 7 December 9th 04 01:59 PM
Problem with graph ranges No Such Luck Charts and Charting in Excel 6 December 3rd 04 01:09 PM
Excel2K: Is it possible to use dynamic named ranges in custom data validation formula? Arvi Laanemets Excel Discussion (Misc queries) 0 December 2nd 04 11:29 AM
Named dynamic ranges, copied worksheets and graph source data WP Charts and Charting in Excel 1 November 28th 04 05:19 PM


All times are GMT +1. The time now is 07:34 PM.

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"