Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 355
Default Help! Limit on number of Ranges you can use at one time?

Hello -

I have the following code:

Dim numBlanks As Integer
numBlanks = 0
'For Each c In Range("D8:D240")
For Each c In Range("D8:D16, D17:D22, D23:D27, D29:D31, D33:D42, D44:D50,
D52:D57, D59:D78, D80:D83, D85:D86," & _
"D88:D94, D102:D105, D107:D111, D113:D115, D123:D128, D135:D136,
D143:D144, D146, D154:D156," & _
"D158:D159, D167:D170, D172:D174, D176, D178:D179, D187:D189, D191:D197,
D212")

'The following line is commented out
', D214:D218, D221:D230, D237:D240")

If c.Value = "" Then
numBlanks = numBlanks + 1
End If
Next c

MsgBox "The number of blank rows is: " & numBlanks

Note I have commented out the code for:
', D214:D218, D221:D230, D237:D240")

This runs fine until I try to put one more range in from the commented line;
e.g. D214:D218 (or either of the other two for that matter). I obviously
need to include these three ranges.

I am getting the following error:
Run-time error '1004'
Method 'Range' or object '_Worksheet' failed.
When I click on the help button of the error, it comes up totally blank.

Is there some limit on the amount of ranges you can use at one time? If
that's the case, is there some kind of workaround? If not, does anyone know
what is causing this?

Any help will be greatly appreciated!
--
Sandy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Help! Limit on number of Ranges you can use at one time?

The line of code is getting too long. Try using the union function to Union a
couple of range objects together...

dim rng1 as range
dim rng2 as range
dim rngAll as range

set rng1 = Range(...)
set rng2 = Range(...)
set rngAll = union(rng1, rng2)
--
HTH...

Jim Thomlinson


"Sandy" wrote:

Hello -

I have the following code:

Dim numBlanks As Integer
numBlanks = 0
'For Each c In Range("D8:D240")
For Each c In Range("D8:D16, D17:D22, D23:D27, D29:D31, D33:D42, D44:D50,
D52:D57, D59:D78, D80:D83, D85:D86," & _
"D88:D94, D102:D105, D107:D111, D113:D115, D123:D128, D135:D136,
D143:D144, D146, D154:D156," & _
"D158:D159, D167:D170, D172:D174, D176, D178:D179, D187:D189, D191:D197,
D212")

'The following line is commented out
', D214:D218, D221:D230, D237:D240")

If c.Value = "" Then
numBlanks = numBlanks + 1
End If
Next c

MsgBox "The number of blank rows is: " & numBlanks

Note I have commented out the code for:
', D214:D218, D221:D230, D237:D240")

This runs fine until I try to put one more range in from the commented line;
e.g. D214:D218 (or either of the other two for that matter). I obviously
need to include these three ranges.

I am getting the following error:
Run-time error '1004'
Method 'Range' or object '_Worksheet' failed.
When I click on the help button of the error, it comes up totally blank.

Is there some limit on the amount of ranges you can use at one time? If
that's the case, is there some kind of workaround? If not, does anyone know
what is causing this?

Any help will be greatly appreciated!
--
Sandy

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 355
Default Help! Limit on number of Ranges you can use at one time?

Hi Jim -

Thanks so much! That worked beautifully!
--
Sandy


"Jim Thomlinson" wrote:

The line of code is getting too long. Try using the union function to Union a
couple of range objects together...

dim rng1 as range
dim rng2 as range
dim rngAll as range

set rng1 = Range(...)
set rng2 = Range(...)
set rngAll = union(rng1, rng2)
--
HTH...

Jim Thomlinson


"Sandy" wrote:

Hello -

I have the following code:

Dim numBlanks As Integer
numBlanks = 0
'For Each c In Range("D8:D240")
For Each c In Range("D8:D16, D17:D22, D23:D27, D29:D31, D33:D42, D44:D50,
D52:D57, D59:D78, D80:D83, D85:D86," & _
"D88:D94, D102:D105, D107:D111, D113:D115, D123:D128, D135:D136,
D143:D144, D146, D154:D156," & _
"D158:D159, D167:D170, D172:D174, D176, D178:D179, D187:D189, D191:D197,
D212")

'The following line is commented out
', D214:D218, D221:D230, D237:D240")

If c.Value = "" Then
numBlanks = numBlanks + 1
End If
Next c

MsgBox "The number of blank rows is: " & numBlanks

Note I have commented out the code for:
', D214:D218, D221:D230, D237:D240")

This runs fine until I try to put one more range in from the commented line;
e.g. D214:D218 (or either of the other two for that matter). I obviously
need to include these three ranges.

I am getting the following error:
Run-time error '1004'
Method 'Range' or object '_Worksheet' failed.
When I click on the help button of the error, it comes up totally blank.

Is there some limit on the amount of ranges you can use at one time? If
that's the case, is there some kind of workaround? If not, does anyone know
what is causing this?

Any help will be greatly appreciated!
--
Sandy

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Help! Limit on number of Ranges you can use at one time?

did you try using the COUNTA function. If yuo know that there are 3 empty
cells(say) that you don't care about then

Sub xxx()
Dim source As Range
Dim iEmpty As Long

Set source = Range("D8:D240")
iEmpty = 3

MsgBox "Empty Cell count = " & _
(source.Cells.Count - Application.WorksheetFunction.CountA(source)) -
iEmpty


End Sub


"Sandy" wrote:

Hi Jim -

Thanks so much! That worked beautifully!
--
Sandy


"Jim Thomlinson" wrote:

The line of code is getting too long. Try using the union function to Union a
couple of range objects together...

dim rng1 as range
dim rng2 as range
dim rngAll as range

set rng1 = Range(...)
set rng2 = Range(...)
set rngAll = union(rng1, rng2)
--
HTH...

Jim Thomlinson


"Sandy" wrote:

Hello -

I have the following code:

Dim numBlanks As Integer
numBlanks = 0
'For Each c In Range("D8:D240")
For Each c In Range("D8:D16, D17:D22, D23:D27, D29:D31, D33:D42, D44:D50,
D52:D57, D59:D78, D80:D83, D85:D86," & _
"D88:D94, D102:D105, D107:D111, D113:D115, D123:D128, D135:D136,
D143:D144, D146, D154:D156," & _
"D158:D159, D167:D170, D172:D174, D176, D178:D179, D187:D189, D191:D197,
D212")

'The following line is commented out
', D214:D218, D221:D230, D237:D240")

If c.Value = "" Then
numBlanks = numBlanks + 1
End If
Next c

MsgBox "The number of blank rows is: " & numBlanks

Note I have commented out the code for:
', D214:D218, D221:D230, D237:D240")

This runs fine until I try to put one more range in from the commented line;
e.g. D214:D218 (or either of the other two for that matter). I obviously
need to include these three ranges.

I am getting the following error:
Run-time error '1004'
Method 'Range' or object '_Worksheet' failed.
When I click on the help button of the error, it comes up totally blank.

Is there some limit on the amount of ranges you can use at one time? If
that's the case, is there some kind of workaround? If not, does anyone know
what is causing this?

Any help will be greatly appreciated!
--
Sandy

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
limit on [h]:mm time format? Stefi Excel Discussion (Misc queries) 14 February 22nd 07 10:30 AM
Limit to number of named ranges before Excel starts messing things up? S Davis Excel Worksheet Functions 3 September 12th 06 08:07 PM
macro to time limit workbook ditchy Excel Discussion (Misc queries) 5 April 26th 05 08:43 AM
How can i work a formula for time limit? Roze Excel Worksheet Functions 2 November 25th 04 02:41 PM
set time limit before closing sheet Maria Johansson Excel Programming 2 October 14th 03 08:00 AM


All times are GMT +1. The time now is 06:04 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"