PC Review


Reply
Thread Tools Rate Thread

autofill formula to dynamic row count

 
 
Peakie
Guest
Posts: n/a
 
      10th Oct 2009
I need help on how to fill formula into dynamic rows. I import data into
column A-K with different row count each time I import. Then I have formula
in column L-W in row 2 which I need to autofill to the last row of column
A-K. Row 1 is my header row. I need a macro that will help me with this task.
Thanks a lot for help.
 
Reply With Quote
 
 
 
 
Barb Reinhardt
Guest
Posts: n/a
 
      10th Oct 2009
I usually do something like this:

lRow = aWS.cells(aWS.Rows.Count,1).end(xlup).row 'Gets last row of column 1

Set myRange = aws.cells(2,1).resize(lrow-2+1,1)

myRange.offset(0,10).formulaR1C1 = "=...." 'Adds the formula 10 columns to
the right of myRange

You may need to adjust the resize. I'm not completely certain that I
resized it correctly.

HTH,
Barb Reinhardt

"Peakie" wrote:

> I need help on how to fill formula into dynamic rows. I import data into
> column A-K with different row count each time I import. Then I have formula
> in column L-W in row 2 which I need to autofill to the last row of column
> A-K. Row 1 is my header row. I need a macro that will help me with this task.
> Thanks a lot for help.

 
Reply With Quote
 
Barb Reinhardt
Guest
Posts: n/a
 
      10th Oct 2009
This post has more info

lRow = aWS.cells(aWS.Rows.Count,1).end(xlup).row 'Gets last row of column 1
lCol = aws.cells(1,aws.columns.count).end(xltoleft).column

Set myRange = aws.cells(2,1).resize(lrow-2+1,1)

for i = 12 to lCol
set myCell = aws.cells(myrange.row,1).offset(0,i)
if myCell.hasformula then
myRange.offset(0,i).formulaR1C1 = _
mycell.formulaR1C1
end if
next i
You may need to adjust the resize. I'm not completely certain that I
resized it correctly.

You may also be able to use FILLDOWN, but I'd have to record something to do
that.


HTH,
Barb Reinhardt


"Peakie" wrote:

> I need help on how to fill formula into dynamic rows. I import data into
> column A-K with different row count each time I import. Then I have formula
> in column L-W in row 2 which I need to autofill to the last row of column
> A-K. Row 1 is my header row. I need a macro that will help me with this task.
> Thanks a lot for help.

 
Reply With Quote
 
Peakie
Guest
Posts: n/a
 
      11th Oct 2009

Thanks a lot, Barb. I will try your suggestio.

"Barb Reinhardt" wrote:

> This post has more info
>
> lRow = aWS.cells(aWS.Rows.Count,1).end(xlup).row 'Gets last row of column 1
> lCol = aws.cells(1,aws.columns.count).end(xltoleft).column
>
> Set myRange = aws.cells(2,1).resize(lrow-2+1,1)
>
> for i = 12 to lCol
> set myCell = aws.cells(myrange.row,1).offset(0,i)
> if myCell.hasformula then
> myRange.offset(0,i).formulaR1C1 = _
> mycell.formulaR1C1
> end if
> next i
> You may need to adjust the resize. I'm not completely certain that I
> resized it correctly.
>
> You may also be able to use FILLDOWN, but I'd have to record something to do
> that.
>
>
> HTH,
> Barb Reinhardt
>
>
> "Peakie" wrote:
>
> > I need help on how to fill formula into dynamic rows. I import data into
> > column A-K with different row count each time I import. Then I have formula
> > in column L-W in row 2 which I need to autofill to the last row of column
> > A-K. Row 1 is my header row. I need a macro that will help me with this task.
> > Thanks a lot for help.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula to count every other column (dynamic range) Darlene Microsoft Excel New Users 6 18th Nov 2008 09:27 PM
Using Count() in Dynamic Formula John Taylor Microsoft Excel Misc 4 3rd Feb 2008 08:11 AM
Autofill formula to last row with data when rows will be dynamic =?Utf-8?B?QSBXYWxsZXI=?= Microsoft Excel Programming 3 20th Jun 2005 03:06 PM
Formula to Count and Return Most common Value in a Dynamic Named Range Tinä Microsoft Excel Misc 1 23rd Oct 2004 11:26 PM
Formula to Count and Return Most common Value in a Dynamic Named Range Tinä Microsoft Excel Misc 1 23rd Oct 2004 04:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:11 AM.