Hi Michael
There is a non-mystical explanation for the result you are obtaining.
The mystical bit is working out what it is without full information. My
vibes tell me that ParentRows does not contain the value 233 at the point
the line of code is executed. To test this I would put
msgbox ParentRows
as a separate line immediately before the line where the problem occurs.
If that does not show the relevant value (233) then there is an error
elsewhere in the code.
If it does we need to consider other issues but let's try that one first.
BTW do you have Option Explicit at the top of the module? If not I would
suggest putting it there. It avoids mis-spelling variables.
You could simplify your code and reduce other issues by avoiding using
selection. Instead of
Range("F2").Select
Selection.autofill Destination:=Range("F2:F" & ParentRows)
Use
Range("F2").autofill Destination:=Range("F2:F" & ParentRows)
Best Regards
David Grugeon
Excel VBA Group Moderator
-----Original Message-----
From: ExcelVBA@yahoogroups.com [mailto:ExcelVBA@yahoogroups.com] On Behalf
Of mickey11030
Sent: Sunday, 11 March 2012 7:07 AM
To: ExcelVBA@yahoogroups.com
Subject: [ExcelVBA] This Can't Be Happening
I have a spreadsheet in which I use a UDF to calculate Customer Price. My
code is:
Sheets("Parents2").Range("F2").Formula = "=CalCustomerPrice(E2)"
Range("F2").Select
Selection.autofill Destination:=Range("F2:F" & ParentRows)
If I step through this code, it works perfectly, but if I execute it, only
F2 contains the correct content. The other cells in Col F are blank. No
error message. ParentRows has a value of 233.
Is there any non-mystical explanation for this behavior?
Thanks,
Michael Trombetta
------------------------------------
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go
here: http://www.mousetrax.com/techtrax to enter the ezine, then search the
ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------Yahoo! Groups Links
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------
Tidak ada komentar:
Posting Komentar