View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
artisdepartis artisdepartis is offline
external usenet poster
 
Posts: 25
Default Object Error: what am i doing wrong??

Tom, thx for this clarification... It is through help like yours that
i learn from my mistakes :-)

@ Susan: your help clarified the problem for me. I did manage to get
it working in time, by rerecording and using that code. (From my
observation that the sheet needed to be selected...)

I hope that someday i can post replies in stead of questions here.
Keep up your generousity in helping!

Now I will improve my macro... I thought i fixed the dateproblem, but
alas... that one is still a bugger :S TBC

On Mar 23, 8:24 pm, Tom Ogilvy
wrote:
I haven't read the full thread, but for the specific part you are highlighting:

You qualify only the range and not the cells within the range. This means
that the range will point to a specific sheet and the cells will point to the
activesheet. When these are the same (as you have observed), the code works.
When not, you get an error.

Fix it like this

With Workbooks("overview_f.xls").Sheets("SPAI")
set startcell = .Range(.Cells(FoundCell.Row,2), _
.Cells(FoundCell.Row, 127))
End With

Range and Both Cells should be preceded with a period.

--
Regards,
Tom Ogilvy



"artisdepartis" wrote:
Just now, by chance i notice that the problem probably is in the way i
address my Workbooks. No idea why, but when i run the macro it gives
an error, if I select the workbook and then continue my macro it
works... weird... still no solution though


On Mar 23, 3:23 pm, "Susan" wrote:
:D
ok. what happens when you step thru the code?
you said you're getting "does not support the property or method", so
i'm assuming that vba can't find one of these workbooks.


Workbooks("overview_f.xls").Sheets("SPAI").Range(C ells(FoundCell.Row,
2), Cells(FoundCell.Row, 127)).Value _
= Workbooks(sFileNameResults).Sheets("SPAI").rLastSp litsPerAI.Value


OR it can't find the sheet, or it can't find the range.
step thru & hover over each of these & see which one it can't find.


to make life easier, i would set variables for these 2 ranges:


dim DestCell as range
dim StartCell as range


set startcell =
Workbooks("overview_f.xls").Sheets("SPAI").Range(C ells(FoundCell.Row,
2), Cells(FoundCell.Row, 127))


set destcell =
Workbooks(sFileNameResults).Sheets("SPAI").rLastSp litsPerAI


then you could add
msgbox destcell.address
and
msgbox startcell.address


to make sure vba knows where they are.
that might help you find the error.
if it knows where both of them are, try
destcell.value = startcell.value


thinks-too-much-susan
:)


On Mar 23, 10:06 am, "artisdepartis" wrote:


Susan, im giving up on the s (This time they were in my code for
sure when i copied it to GoogleGroups... ;-)


You are right, the error occurs in this bit:
Workbooks("overview_f.xls").Sheets("SPAI").Range(C ells(FoundCell.Row,
2), Cells(FoundCell.Row, 127)).Value _
= Workbooks(sFileNameResults).Sheets("SPAI").rLastSp litsPerAI.Value


I checked and the setting of FoundCell works fine, even though i dont
completely get why... I had the same thoughts as you on that, but this
works... so that is okay enough, even though i dont fully understand
it... (Timepressure :S)
This FoundCell basically is the Row on which I want to insert my
results in my overview file. The reason i want to do it like this, is
I want to avoid the Clipboard. (Our system is VERY slow).


To give you an idea:
copying it via
Workbooks(sFileNameResults).Sheets("SPLITS PER AI").Range(Cells(3, 1),
Cells(3, LSPAI)).Select
Selection.Copy


and pasting it via
FoundCell.Offset(0, 1).Select
ActiveCell.PasteSpecial xlPasteValues


Does work, but since i need to do these with more data this becomes
very code and memory inefficient...


Thx for thinking along ^^- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -