I am trying to use a string to select some cells by using Range(MaPlage), but this doesn't work. Here is the code and how I constructed the string:
Dim MaPlage As String
Dim MyRange As Range
Dim Line As Integer
Dim AdrRD as String
Dim First_Cell As Boolean
First_Cell = True
AdrRD = "A"
For Line = 1 To 100 Step 1
If Sheet.Range(AdrRD & Line).Value = "" Then
If First_Cell = True Then
MaPlage = AdrRD & Line
First_Cell = False
Else
MaPlage = MaPlage & ", " & AdrRD & Line
End If
End If
Next Line
If MaPlage <> "" Then
Range(MaPlage).Select
Selection.EntireRow.Delete
End If
There is an error at "Range(MaPlage).Select"
I have also tried Set MyRange = Range(MaPlage) but it gives me the same error.
Excel gives me the error in French but it's something like: "Error 1004: The 'Range' method from the object '_Global' has failed."
Thanks a lot!
EDIT: I just tried with
For Line = 1 To 40 Step 1
Instead of 100, and it worked correctly. Does this mean that when the selection goes all the way to line 100 it is to big ?