Solved

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

Posted on 2013-06-20
6
624 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
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.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

705 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now