Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default How Can I Check Multiple Ranges?

Thanks to this forum, I now know how to check a range with multiple cells to determine if it is blank. My next challenge is to check all the ranges in all of the worksheets in my workbook to ensure they are all blank before starting my procedure. I want to do this in Visual Basic but have no idea how to begin. I have about 15 range names I need to check. Should I be "looping" through relative or absolute sheetnames or range names ? Or should I be using Nested If Statements, or some third alternative? Any sample code would be greatly appreciated (as always).

Sincerely,

Fred

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How Can I Check Multiple Ranges?

Fred

Therre is know 'right way' to do this. But if you can
refer to previously created named ranges in your code.

Sub ClearRange()
Application.Goto Reference:="MyBook.xls!MyRange"
Selection.ClearContents
End Sub

Sub ApplyColor()
Const limit As Integer = 25
For Each c In Range("MyRange")
If c.Value limit Then
c.Interior.ColorIndex = 27
End If
Next c
End Sub

Using named ranges in the code means you do not have to
refer to the worksheet in the code. So if the ranges are
fixed use names but if they are dynamic and being added to
then use cell references.

nr = application.worksheetfunction.counta(range("A:A"))
rng = range(cells(1,1),cells(nr,6)
the rest of your code here

Regards
Peter
-----Original Message-----
Thanks to this forum, I now know how to check a range

with multiple cells to determine if it is blank. My next
challenge is to check all the ranges in all of the
worksheets in my workbook to ensure they are all blank
before starting my procedure. I want to do this in Visual
Basic but have no idea how to begin. I have about 15
range names I need to check. Should I be "looping"
through relative or absolute sheetnames or range names ?
Or should I be using Nested If Statements, or some third
alternative? Any sample code would be greatly appreciated
(as always).

Sincerely,

Fred

.

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
Check value against multiple ranges X-Ray Excel Worksheet Functions 3 September 24th 08 05:52 PM
Multiple IF statements looking up multiple ranges. mike Excel Worksheet Functions 7 August 9th 07 04:55 PM
Can I create Multiple passwords to edit multiple ranges? Conker10382 Excel Discussion (Misc queries) 8 December 31st 06 07:58 PM
How do i update multiple data ranges across multiple worksheets? mwah Excel Discussion (Misc queries) 0 July 6th 06 04:57 AM
Printing Multiple Ranges from Multiple Worksheets Dave Barkley[_2_] Excel Programming 1 July 22nd 03 06:10 PM


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

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"