LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Using VB to to create named ranges

Hi,

This is a two part question that may have one answer.

1. I'm using the following code to create a named range of **everything** on
a worksheet:

Sub CreateRangeName()

Dim first_row As Integer
Dim first_col As Integer
Dim num_rows As Integer
Dim num_cols As Integer
Dim rng As String

With ActiveSheet
first_row = .UsedRange.Row
first_col = .UsedRange.Column
num_rows = .UsedRange.Rows.Count
num_cols = .UsedRange.Columns.Count
End With

rng = "R" & first_row & "C" & first_col & ":R" & num_rows & "C" & num_cols

ActiveWorkbook.Names.Add Name:="RangeName", RefersToR1C1:="=" & rng

End Sub

This works fine on a worksheet where I want to select everything but there
maybe occasion where I want to **leave out a section** from the range. Is
there a better way I could code this so I can be more specific about the
range I want to name but without hardcoding cell addresses.

Thanks


 
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
Named Ranges in Excel (update and create) Ixtreme Excel Discussion (Misc queries) 2 June 17th 09 03:23 PM
Rapidly Create a Large Number of Named Ranges Thomas M. Excel Worksheet Functions 0 May 7th 09 07:09 PM
Create list of Named Ranges Jim Tibbetts Excel Worksheet Functions 4 February 15th 07 05:29 PM
Like 123, allow named ranges, and print named ranges WP Excel Discussion (Misc queries) 1 April 8th 05 06:07 PM
named ranges - changing ranges with month selected gr8guy Excel Programming 2 May 28th 04 04:50 AM


All times are GMT +1. The time now is 08:58 AM.

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"