VBA AutoDrag Help Please

NataliaMSN

New Member
Joined
Mar 16, 2011
Messages
5
Hello I heard this forum is the best .
I was having some sytax issues with a formula in VBA.
I was stuck on the portion of my code with the range of my autodrag function . . .

I have a formula that I want to auto drag down to the row where my data stops in Column A.
My formula is starting in D3 and I want it to autodrag using Column A as a reference to drag.
I need to do it that way because B and C do not necessary have data in every row thats why I need to use A as the reference.
I was Attempting to use the "AutoFill Destination:" VBA Function but I am confused as to how to specify my range after that can someone help me out please.

Sorry, I am relatively new to VBA.

I am using Excel 2010.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hi,
This doesn't use the AutoFil function but I find it a useful thing to know.
Code:
Range("D3").Resize(Range("A3").End(xlDown).Row - 2, 1).Value = "=SUM(A3+1)"
The example assumes there are no blank rows in column 'A', it just adds 1 to the value in column 'A', you can change that for the formula you need.

Note: The resize section is getting the last used row in column 'A' and taking 2 away (as you are starting in row 3). It is then seeing how many columns you need, in this instance just 1.
 
Upvote 0
Here's one way:

Code:
Range("D3").AutoFill _
    Destination:=Range("D3", Cells(Cells(Rows.Count, "A").End(xlUp).Row, "D"))
 
Upvote 0
Ok I think I understand what you are saying and it works for the problem I mentioned but I guess I am not understanding what Row part of the equation because I am trying to use this formula again in the column "P" and I wanted to use Column "J" as a Reference like I did previously and my formula is:
=IF(AND(M3="Y",I3="H"),1,0) for some reason I'm not getting it right
 
Upvote 0
Okay...

The following starts at the range 'P3' and extends the range to match the number of rows in column 'J'. If there is data in cells 'J3' through to 'J50' then it extends the range to be 'P3:P50'

It then puts the formula into all of the cells. Example below.
Code:
Range("P3").Resize(Range("J3").End(xlDown).Row - 2, 1).Value = "=IF(AND(M3="Y",I3="H"),1,0)"

Hope that makes some sense ?
 
Upvote 0
Nevermind sorry I was in the process of posting when that other post was placed.
Thank you my friend from the great state of Texas that works.
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top