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: 29
Default Validating that named ranges exist

Hello,
I'm here yet again to seek the help of the gurus.

I have this bit of code for a button click on one of my spreadsheets.

Private Sub btnCreateRanges_Click()
Application.ScreenUpdating = False
Dim ordLastRow As Long
Dim revLastRow As Long
Dim revSheet As Worksheet
Dim ordSheet As Worksheet
Set revSheet = Sheets("REVENUE")
Set ordSheet = Sheets("ORDERS")
ordLastRow = ordSheet.UsedRange.Rows.Count
revLastRow = revSheet.UsedRange.Rows.Count
ordSheet.Range("B2:B" & ordLastRow).Name = "OrdersCountry"
ordSheet.Range("D2:D" & ordLastRow).Name = "OrdersYear"
ordSheet.Range("E2:E" & ordLastRow).Name = "OrdersMonth"
ordSheet.Range("F2:F" & ordLastRow).Name = "OrdersOffering"
ordSheet.Range("G2:G" & ordLastRow).Name = "OrdersAmount"
revSheet.Range("B2:B" & revLastRow).Name = "RevenueCountry"
revSheet.Range("D2:D" & revLastRow).Name = "RevenueYear"
revSheet.Range("E2:E" & revLastRow).Name = "RevenueMonth"
revSheet.Range("F2:F" & revLastRow).Name = "RevenueOffering"
revSheet.Range("G2:G" & revLastRow).Name = "RevenueAmount"
Application.ScreenUpdating = True
End Sub

The code figures out the last used row on two worksheets and then creates
named ranges for certain columns. I use those named ranges on other parts of
the Workbook and the number of rows grows every month, so the ranges change
every month.
My question is:
Do I need to implement some sort of validation point to check if the named
ranges exist on the Workbook before setting them again (new button click) ?
If so, is there a way that I can check for all 6 named ranges at once? Or
do I have to validate one by one?

Thanks
Juan Correa
 
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 scope / workbook/worksheet level named ranges- changeswith variable use... christian_spaceman Excel Programming 3 December 24th 07 01:15 PM
Question relating to Named Ranges which exist in another workbook. Pank Excel Discussion (Misc queries) 2 February 5th 07 03:17 PM
Copy data in named ranges to a newer version of the same template to identical ranges handstand Excel Programming 0 August 21st 06 03:51 PM
Event validating two ranges with dates G R E G Excel Programming 1 August 9th 03 12:03 AM


All times are GMT +1. The time now is 07:19 AM.

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"