Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Does Range("A1,B2,C3,etc") have a max number of cells?


I am having an issue with a macro that I wrote, it takes a range 236row
by 100 columns and then creates a new range that is only cells wit
values in them, or rather it removes all the blanks (Which their ten
to be quite a bit). Excel crashes consistently when I am running this
If there is a max, what is it? Maybe there is a better way for me t
approach this problem.

Thank you in advance for your help,

The code for removing the blanks is as follows... The CombineRang
function acts much like Union, but It checks to make sure tha
RemoveBlanks and CurrCell are in fact already ranges.

Function RemoveBlanks(myRange As Range) As Range
Dim CurrCell As Range
For Each CurrCell In myRange
If Not Len(CurrCell.Formula) = 0 Then
Set RemoveBlanks = CombineRange(RemoveBlanks, CurrCell)
End If
Next
ErrHandler:
With Err
If Not .Number = 0 Then
.Raise .Number, "mdlFormat:RemoveBlanks" & vbCrLf & .Source
.Description
End If
End With
End Functio

--
kralj
-----------------------------------------------------------------------
kraljb's Profile: http://www.excelforum.com/member.php...nfo&userid=995
View this thread: http://www.excelforum.com/showthread.php?threadid=39516

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Does Range("A1,B2,C3,etc") have a max number of cells?

I think this is what you are looking for...

Sub test()
Call RemoveBlanks(Sheet1.UsedRange)
End Sub

Public Sub RemoveBlanks(ByVal rng As Range)
rng.SpecialCells(xlBlanks).Delete
End Sub
--
HTH...

Jim Thomlinson


"kraljb" wrote:


I am having an issue with a macro that I wrote, it takes a range 236rows
by 100 columns and then creates a new range that is only cells with
values in them, or rather it removes all the blanks (Which their tend
to be quite a bit). Excel crashes consistently when I am running this.
If there is a max, what is it? Maybe there is a better way for me to
approach this problem.

Thank you in advance for your help,

The code for removing the blanks is as follows... The CombineRange
function acts much like Union, but It checks to make sure that
RemoveBlanks and CurrCell are in fact already ranges.

Function RemoveBlanks(myRange As Range) As Range
Dim CurrCell As Range
For Each CurrCell In myRange
If Not Len(CurrCell.Formula) = 0 Then
Set RemoveBlanks = CombineRange(RemoveBlanks, CurrCell)
End If
Next
ErrHandler:
With Err
If Not .Number = 0 Then
.Raise .Number, "mdlFormat:RemoveBlanks" & vbCrLf & .Source,
.Description
End If
End With
End Function


--
kraljb
------------------------------------------------------------------------
kraljb's Profile: http://www.excelforum.com/member.php...fo&userid=9955
View this thread: http://www.excelforum.com/showthread...hreadid=395160


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Does Range("A1,B2,C3,etc") have a max number of cells?


Thanks for the help Jim, but that was not what I was looking for
although it did help me get what I needed...

Function RemoveBlanks2(myRange As Range) As Range
Set RemoveBlanks2
CombineRange(myRange.SpecialCells(xlCellTypeFormul as), _
myRange.SpecialCells(xlCellTypeConstants))
End Functio

--
kralj
-----------------------------------------------------------------------
kraljb's Profile: http://www.excelforum.com/member.php...nfo&userid=995
View this thread: http://www.excelforum.com/showthread.php?threadid=39516

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
Count the number of cells that conatin a "." in a range Jonathan Brown Excel Worksheet Functions 5 February 5th 09 11:00 PM
Using "=randbetween" to select a number from a range of cells a0xbjzz Excel Worksheet Functions 4 August 4th 07 07:47 PM
Multiple "Range" with "Cells" property? jopu[_2_] Excel Programming 3 November 18th 04 04:05 PM
Multiple "Range" with "Cells" property? jopu Excel Programming 2 November 18th 04 02:38 PM
Using "Cells" to write "Range("A:A,H:H").Select" Trip Ives[_2_] Excel Programming 3 June 5th 04 03:13 PM


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