Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-06-20
6
Medium Priority
?
700 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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 600 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

650 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