Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Contiguous Ranges and 255 Char Limit Constraint

I know I can pass all the contiguous ranges of cells with formulas as follows
below. However this suffers from the 255 char limit. That is, if the range
is greater than 255 then the cell address that is passed to the ContRange
variable will be truncated. How do you get around this?

Sub test2()
Dim sht As Worksheet
Dim ContRange As String

For Each sht In ThisWorkbook.Worksheets
Set rng1 = sht.Range("a1:iv65536").Cells.SpecialCells(xlFormu las)
ContRange = rng1.Address
Debug.Print sht.Name
Debug.Print ContRange
Debug.Print Len(ContRange)
Next

End Sub

Thanks

EM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Contiguous Ranges and 255 Char Limit Constraint

dim rArea as Range
For each rArea in rng1.Areas

do something with rArea,
but don't bother rebuilding a 255+ address because it'll fail when you try
to use it (depending on what you are doing)

Regards,
Peter T

"ExcelMonkey" wrote in message
...
I know I can pass all the contiguous ranges of cells with formulas as
follows
below. However this suffers from the 255 char limit. That is, if the
range
is greater than 255 then the cell address that is passed to the ContRange
variable will be truncated. How do you get around this?

Sub test2()
Dim sht As Worksheet
Dim ContRange As String

For Each sht In ThisWorkbook.Worksheets
Set rng1 = sht.Range("a1:iv65536").Cells.SpecialCells(xlFormu las)
ContRange = rng1.Address
Debug.Print sht.Name
Debug.Print ContRange
Debug.Print Len(ContRange)
Next

End Sub

Thanks

EM



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Contiguous Ranges and 255 Char Limit Constraint

Excellent Point Peter. This works:

Sub test2()
Dim sht As Worksheet
Dim ContRange As String

For Each sht In ThisWorkbook.Worksheets
ContRange = ""
Counter = 0
Set rng1 = sht.Range("a1:iv65536").Cells.SpecialCells(xlFormu las)
For Each myArea In rng1.Areas
If Counter = 0 Then
ContRange = myArea.Address
Else
ContRange = ContRange & "," & myArea.Address
End If
Counter = Counter + 1
Next
Debug.Print sht.Name
Debug.Print ContRange
Next

End Sub


"Peter T" wrote:

dim rArea as Range
For each rArea in rng1.Areas

do something with rArea,
but don't bother rebuilding a 255+ address because it'll fail when you try
to use it (depending on what you are doing)

Regards,
Peter T

"ExcelMonkey" wrote in message
...
I know I can pass all the contiguous ranges of cells with formulas as
follows
below. However this suffers from the 255 char limit. That is, if the
range
is greater than 255 then the cell address that is passed to the ContRange
variable will be truncated. How do you get around this?

Sub test2()
Dim sht As Worksheet
Dim ContRange As String

For Each sht In ThisWorkbook.Worksheets
Set rng1 = sht.Range("a1:iv65536").Cells.SpecialCells(xlFormu las)
ContRange = rng1.Address
Debug.Print sht.Name
Debug.Print ContRange
Debug.Print Len(ContRange)
Next

End Sub

Thanks

EM




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Contiguous Ranges and 255 Char Limit Constraint

That looks fine but what's the ultimate objective, particularly if that
address length is 255+

Regards,
Peter T

"ExcelMonkey" wrote in message
...
Excellent Point Peter. This works:

Sub test2()
Dim sht As Worksheet
Dim ContRange As String

For Each sht In ThisWorkbook.Worksheets
ContRange = ""
Counter = 0
Set rng1 = sht.Range("a1:iv65536").Cells.SpecialCells(xlFormu las)
For Each myArea In rng1.Areas
If Counter = 0 Then
ContRange = myArea.Address
Else
ContRange = ContRange & "," & myArea.Address
End If
Counter = Counter + 1
Next
Debug.Print sht.Name
Debug.Print ContRange
Next

End Sub


"Peter T" wrote:

dim rArea as Range
For each rArea in rng1.Areas

do something with rArea,
but don't bother rebuilding a 255+ address because it'll fail when you
try
to use it (depending on what you are doing)

Regards,
Peter T

"ExcelMonkey" wrote in message
...
I know I can pass all the contiguous ranges of cells with formulas as
follows
below. However this suffers from the 255 char limit. That is, if the
range
is greater than 255 then the cell address that is passed to the
ContRange
variable will be truncated. How do you get around this?

Sub test2()
Dim sht As Worksheet
Dim ContRange As String

For Each sht In ThisWorkbook.Worksheets
Set rng1 = sht.Range("a1:iv65536").Cells.SpecialCells(xlFormu las)
ContRange = rng1.Address
Debug.Print sht.Name
Debug.Print ContRange
Debug.Print Len(ContRange)
Next

End Sub

Thanks

EM






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Contiguous Ranges and 255 Char Limit Constraint

Set rng1 = sht.Range("a1:iv65536").Cells.SpecialCells(xlFormu las)

A small point but this could be a little shorter and work in Excel 2007 too:

Set rng1 = sht.Cells.SpecialCells(xlFormulas)

--
Jim
"ExcelMonkey" wrote in message
...
| Excellent Point Peter. This works:
|
| Sub test2()
| Dim sht As Worksheet
| Dim ContRange As String
|
| For Each sht In ThisWorkbook.Worksheets
| ContRange = ""
| Counter = 0
| Set rng1 = sht.Range("a1:iv65536").Cells.SpecialCells(xlFormu las)
| For Each myArea In rng1.Areas
| If Counter = 0 Then
| ContRange = myArea.Address
| Else
| ContRange = ContRange & "," & myArea.Address
| End If
| Counter = Counter + 1
| Next
| Debug.Print sht.Name
| Debug.Print ContRange
| Next
|
| End Sub
|
|
| "Peter T" wrote:
|
| dim rArea as Range
| For each rArea in rng1.Areas
|
| do something with rArea,
| but don't bother rebuilding a 255+ address because it'll fail when you
try
| to use it (depending on what you are doing)
|
| Regards,
| Peter T
|
| "ExcelMonkey" wrote in message
| ...
| I know I can pass all the contiguous ranges of cells with formulas as
| follows
| below. However this suffers from the 255 char limit. That is, if the
| range
| is greater than 255 then the cell address that is passed to the
ContRange
| variable will be truncated. How do you get around this?
|
| Sub test2()
| Dim sht As Worksheet
| Dim ContRange As String
|
| For Each sht In ThisWorkbook.Worksheets
| Set rng1 = sht.Range("a1:iv65536").Cells.SpecialCells(xlFormu las)
| ContRange = rng1.Address
| Debug.Print sht.Name
| Debug.Print ContRange
| Debug.Print Len(ContRange)
| Next
|
| End Sub
|
| Thanks
|
| EM
|
|
|



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Contiguous Ranges and 255 Char Limit Constraint

Effectively I want to be able to isolate each contiguous range on each sheet.
I then want to be able to test to see if a specific cell falls within one of
those ranges (True/False). Given that the Range("a1:iv65536")) will never
exceed 255, I should not run into any 255 char limits. Given that each
myArea In rng1.Areas will be contiguous, they too will not exceed the 255
limit. I agree that the joining them in the string variable will potentially
exceed 255. However I will use the Split function to send them all
separately to a collection object or array and only deal with separately.

Regards

RK

"Peter T" wrote:

That looks fine but what's the ultimate objective, particularly if that
address length is 255+

Regards,
Peter T

"ExcelMonkey" wrote in message
...
Excellent Point Peter. This works:

Sub test2()
Dim sht As Worksheet
Dim ContRange As String

For Each sht In ThisWorkbook.Worksheets
ContRange = ""
Counter = 0
Set rng1 = sht.Range("a1:iv65536").Cells.SpecialCells(xlFormu las)
For Each myArea In rng1.Areas
If Counter = 0 Then
ContRange = myArea.Address
Else
ContRange = ContRange & "," & myArea.Address
End If
Counter = Counter + 1
Next
Debug.Print sht.Name
Debug.Print ContRange
Next

End Sub


"Peter T" wrote:

dim rArea as Range
For each rArea in rng1.Areas

do something with rArea,
but don't bother rebuilding a 255+ address because it'll fail when you
try
to use it (depending on what you are doing)

Regards,
Peter T

"ExcelMonkey" wrote in message
...
I know I can pass all the contiguous ranges of cells with formulas as
follows
below. However this suffers from the 255 char limit. That is, if the
range
is greater than 255 then the cell address that is passed to the
ContRange
variable will be truncated. How do you get around this?

Sub test2()
Dim sht As Worksheet
Dim ContRange As String

For Each sht In ThisWorkbook.Worksheets
Set rng1 = sht.Range("a1:iv65536").Cells.SpecialCells(xlFormu las)
ContRange = rng1.Address
Debug.Print sht.Name
Debug.Print ContRange
Debug.Print Len(ContRange)
Next

End Sub

Thanks

EM






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
255 char limit on TextBox ep Excel Programming 3 July 8th 08 11:54 PM
Help Programming Limit Constraint Suz84[_3_] Excel Programming 5 August 2nd 06 03:06 PM
Help Programming Limit Constraint Suz84[_2_] Excel Programming 0 August 2nd 06 01:58 PM
How do I get around the 255 char limit? Dave H Links and Linking in Excel 3 June 13th 06 01:25 PM
Limit to 50 char only singkit Excel Programming 2 April 2nd 04 01:34 AM


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