ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Auto filling using macros (https://www.excelbanter.com/excel-programming/336658-auto-filling-using-macros.html)

Bernard

Auto filling using macros
 
I have a spreadsheet that I need to reformat each month in order for it to be
imported into another application. The spreadsheet varies in length each
month, from say 100 lines one month to 600 lines the following month.

I have recorded a macro that deletes columns, creates formulae etc.
I wish to 'auto fill' the formulae I create down the entire length of a
column. However, the fact that the spreadsheet has a different number of
lines each month means that performing the autofill via a simple macro does
not work.

I know there is a bit of code that will allow me to find the last line in
the spreadsheet and autofill down to that line but I can't remember how to do
it. Any suggestions?

Thanks in advance

Mike Fogleman

Auto filling using macros
 
Here is an example code:

Range("B2").Formula = "=LOOKUP(A2,'Employee Numbers'!C:D)"
If Range("A3") "" Then
Range("B2", Range("A2").End(xlDown)).Offset(0, 1).FillDown
End If

This uses the last row of column A [Range("A2").End(xlDown))] as where to
fill down the formula in column B from B2.

Mike F
"bernard" wrote in message
...
I have a spreadsheet that I need to reformat each month in order for it to
be
imported into another application. The spreadsheet varies in length each
month, from say 100 lines one month to 600 lines the following month.

I have recorded a macro that deletes columns, creates formulae etc.
I wish to 'auto fill' the formulae I create down the entire length of a
column. However, the fact that the spreadsheet has a different number of
lines each month means that performing the autofill via a simple macro
does
not work.

I know there is a bit of code that will allow me to find the last line in
the spreadsheet and autofill down to that line but I can't remember how to
do
it. Any suggestions?

Thanks in advance




Bernard

Auto filling using macros
 
Thanks!

"Mike Fogleman" wrote:

Here is an example code:

Range("B2").Formula = "=LOOKUP(A2,'Employee Numbers'!C:D)"
If Range("A3") "" Then
Range("B2", Range("A2").End(xlDown)).Offset(0, 1).FillDown
End If

This uses the last row of column A [Range("A2").End(xlDown))] as where to
fill down the formula in column B from B2.

Mike F
"bernard" wrote in message
...
I have a spreadsheet that I need to reformat each month in order for it to
be
imported into another application. The spreadsheet varies in length each
month, from say 100 lines one month to 600 lines the following month.

I have recorded a macro that deletes columns, creates formulae etc.
I wish to 'auto fill' the formulae I create down the entire length of a
column. However, the fact that the spreadsheet has a different number of
lines each month means that performing the autofill via a simple macro
does
not work.

I know there is a bit of code that will allow me to find the last line in
the spreadsheet and autofill down to that line but I can't remember how to
do
it. Any suggestions?

Thanks in advance





LadyHawk

Auto filling using macros
 
I have a question about this Macro
My understanding is it looks at column A to determine how far to fill Column
B starting with cell B2.
What exactly does this portion

"=LOOKUP(A2,'Employee Numbers'!C:D)"

Have to do with it...I am getting some sort of error when I attempt to use
this macro in my spreadsheet

"Mike Fogleman" wrote:

Here is an example code:

Range("B2").Formula = "=LOOKUP(A2,'Employee Numbers'!C:D)"
If Range("A3") "" Then
Range("B2", Range("A2").End(xlDown)).Offset(0, 1).FillDown
End If

This uses the last row of column A [Range("A2").End(xlDown))] as where to
fill down the formula in column B from B2.

Mike F
"bernard" wrote in message
...
I have a spreadsheet that I need to reformat each month in order for it to
be
imported into another application. The spreadsheet varies in length each
month, from say 100 lines one month to 600 lines the following month.

I have recorded a macro that deletes columns, creates formulae etc.
I wish to 'auto fill' the formulae I create down the entire length of a
column. However, the fact that the spreadsheet has a different number of
lines each month means that performing the autofill via a simple macro
does
not work.

I know there is a bit of code that will allow me to find the last line in
the spreadsheet and autofill down to that line but I can't remember how to
do
it. Any suggestions?

Thanks in advance






All times are GMT +1. The time now is 12:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com