I'm trying to ask Excel to determine what is the range that I want to
define. The following is the code:
**********************************************************************
Dim MyRange As Range
Dim i, j As Integer
j = 0
For i = 1 To 100
If Cells(i, 1) <> "" Then
j = j + 1
Else
End If
Next i
Set MyRange = Sheets("Sheet3").Range("A1").CurrentRegion
'Set MyRange = Sheets("Sheet3").Range(Cells(1, 1), Cells(j,
7))
ActiveWorkbook.Names.Add Name:="Realized_Result",
RefersToR1C1:=MyRange
****************************************************************
As you can see, I actually wanted to define the range as the ones
that gives me non-blank cell blocks. But somehow the code didn't
work. I switched to Range("A1").currentregion and it worked. But
that's not what I want because it included some empty cells. So does
anybody know what I did wrong?