View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
David David is offline
external usenet poster
 
Posts: 2
Default Range Objects + Names + Error 1004

On Mar 15, 10:55*am, Dave Peterson wrote:
Maybe fully qualifying that range would help:

Set rng = Worksheets("Master").Range("Clothing")
(guessing that Clothing is on the Master worksheet)

You may want to double check your spelling of the name, too. *Maybe it was a
typo.





David wrote:

I seem to be running into the 1004 error on what I thought would be
something simple. *I have created 4 names
one of which is "Clothing", it refers to cells B4 to B8. *I want to
simply place the arrData into each of the five cells.
I can't get past that line setting the range object. *I thought
setting range objects was easy. *The range is already named what is
causing this error? * A piece of the offending code follows: *Is there
some "rule of thumb" to follow when setting and using range objects, I
always seem to be getting thrown with them. *Thanks David.


Public Sub ApplyData()


Dim i As Integer
Dim j As Integer
Dim rng As Range


Sheets("Master").Activate


Set rng = Range("Clothing") * * * ' Can't get past this line
rng.Cells(1) = arrData(0, 0)
rng.Cells(2) = arrData(0, 1)
rng.Cells(3) = arrData(0, 2)
rng.Cells(4) = arrData(0, 3)
rng.Cells(5) = arrData(0, 4)
* *.
* *.
* *.
End sub


As Always Much appreciated!


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Thanks for your answer, unfortunately I'm still getting the error. I
'm starting to think there is something wrong with the names procedure
that I used. It is:

Sheets("Master").Activate
Range("B4").Select
Set rng = Range(ActiveCell.Address, "B27")

For i = 0 To rng.Rows.Count - 1
rng.Cells(i + 1).Select
If ActiveCell.Value = "Black" Then ' each time it
encounters "Black" (down the column), the cell to the left is what I
want the name to be. (Createnames ' 'doesn't work).
strName = ActiveCell.Offset(0, -1).Value
strAdd1 = ActiveCell.Address
strAdd2 = ActiveCell.Offset(4, 0).Address
strRange = strAdd1 & ":" & strAdd2
strSheet = "Master!"
ThisWorkbook.Names.Add Name:=strSheet & strName,
RefersTo:=strRange
End If
Next i

MsgBox "Names Created", vbInformation

Another interesting but frustrating thing is that the names box (on
the left side of the toolbar in the Excel GUI), doesn't show any of
the names.
This has excellerated my aging process!!
Thanks