Solved

Excel Auto Fill Rows with a formula based on length of previous column

Posted on 2013-06-20
6
674 Views
Last Modified: 2013-06-20
Hello Experts,

I have an excel output created by a database.  What I need to do is create a macro that will auto fill in a formula down a column to the length of the previous column.

For example:

N2 - N205 (can be varied length, exp. N2 - N602)  Then place a formula in column O2 - O205

Thanks!
0
Comment
Question by:CompTech810
  • 3
  • 3
6 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 39262663
Something like:
Range("O2:O" & Cells(rows.count, "N").end(xlup).row).Formula = "=your_formula_here"

Open in new window

0
 
LVL 2

Author Comment

by:CompTech810
ID: 39262705
I tried your code and I get this error: Application-defined or object-defined error.
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 39262795
What did you put in for your formula?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:CompTech810
ID: 39262825
Range("O2:O" & Cells(Rows.Count, "N").End(xlUp).Row).Formula = "=IF(COUNTIF($N2:N$2,N2)>1,"",N2)"

Open in new window

0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 150 total points
ID: 39262934
You need to double the quotes for any quotes within the formula string:

Range("O2:O" & Cells(Rows.Count, "N").End(xlUp).Row).Formula = "=IF(COUNTIF($N2:N$2,N2)>1,"""",N2)"

Open in new window

0
 
LVL 2

Author Closing Comment

by:CompTech810
ID: 39263255
Awesome, that worked!  Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question