View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
kassie kassie is offline
external usenet poster
 
Posts: 515
Default Is there a limit to the number of items you can select?

Declare your variable as type long, iso as type integer: Dim LengthofSelect
as Long

--
Hth

Kassie Kasselman
Change xxx to hotmail


"pokdbz" wrote:

I have the VBA code listed below.
I get an error Run-time error 1004
Method 'Range' of object '_Global' failed

Basicly what I want to do is select all rows with Column C = Independent

When I run it with lengthofselect = 79340 the error occurs on the
Range(RowNumHolderNew).Select statment

When I run it with lengthofselect = 16 it runs fine and selects the Rows I
want it to.

Is there a limit that you can only select so many rows at once in the
Range() function?

Do you have a simpler way of doing this?


i = 1

Do While Range("C" & i) < ""

If Range("C" & i).Value = "Independent" Then
RowNumHolder = i & ":" & i & "," & RowNumHolder

End If
i = i + 1
Loop

lengthofselect = Len(RowNumHolder)
RowNumHolderNew = Mid(RowNumHolder, 1, lengthofselect - 1) 'removes last
comma
Range(RowNumHolderNew).Select