MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Using VBA to name Ranges

  Asked By: Fabiana    Date: Mar 24    Category: MS Office    Views: 1945

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
End If
Next i
Set MyRange = Sheets("Sheet3").Range("A1").CurrentRegion
'Set MyRange = Sheets("Sheet3").Range(Cells(1, 1), Cells(j,

ActiveWorkbook.Names.Add Name:="Realized_Result",

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?



No Answers Found. Be the First, To Post Answer.

Didn't find what you were looking for? Find more on Using VBA to name Ranges Or get search suggestion and latest updates.