Hi,
I have defined Numrows as an integer.
I want to use the following code :-
But rather than M410, I want the code to copy down to "numrows"![]()
Please Login or Register to view this content.
How can I code this?
Thanks in advance
Hi,
I have defined Numrows as an integer.
I want to use the following code :-
But rather than M410, I want the code to copy down to "numrows"![]()
Please Login or Register to view this content.
How can I code this?
Thanks in advance
Last edited by bd528; 03-07-2010 at 04:59 AM.
Hi,
You can try
HTHSelection.AutoFill Destination:=Range("M6:M"&Numrows)
It's not clear what you're "filling" - formula/value etc... it's generally quicker to apply to a contiguous range using the below approach as opposed to AutoFill.
If we assume numrows is 10 then M6:M10 will assume the formula of the first cell in the selection.![]()
Please Login or Register to view this content.
If numrows is meant to represent the size of the vector rather than the literal end row number (implied by naming convention - ie number of rows) then you would use Resize
this would apply the formula to M6:M15 (10x1)![]()
Please Login or Register to view this content.
If you're still having problems post a sample.
(we assume the sheet is unprotected etc...)
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
I have attached an example.
I want to copy the forumula down to the last row (based on the number of entries in column A)
I have used a seperate piece of code (not in the example) to count the number of entries in column A, which creates the integer "numrows". But if you know a better solution to counting them, please let me know.
Thanks.
Sorry, just looked at this...
![]()
Please Login or Register to view this content.
Thanks for that - its nearly perfect.
Please see my ammended attachment. I'd like L5 to remain blank if possible, after the macro is complete. I realise I could just use another piece of code to remove the current contents on the cell, but I assume you will know how to adjust your example.
Thanks again.
Change the reference from 5 to 6
If I do that, I get #VALUE! in M6
I should perhaps have been more explicit
![]()
Please Login or Register to view this content.
No, not at all - I should have seen my mistake! Thank you thats great.
As for my original question, (just so I know for future reference, and understand the syntax) in the code below, how can I refer to an integer variable row number, rather than 410?
![]()
Please Login or Register to view this content.
Last edited by bd528; 03-06-2010 at 05:56 PM.
You would use something along the lines of:
Note: numrows should be declared as Long rather than Integer![]()
Please Login or Register to view this content.
Long is advised when working with Row values given Row numbers can exceed Integer boundaries thereby generating overflow errors
It is also assumed that numrows holds the last row number of interest rather than the count of rows to be included - if it is the latter then use a Resize based approach.
Thanks again. Exactly the information I needed.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks