ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Don't Copy If Null -- Help (https://www.excelbanter.com/excel-programming/379893-dont-copy-if-null-help.html)

Ardy

Don't Copy If Null -- Help
 
I have generated a code with help of macro's that will select a range
and then Auto fills it to a given range. It all works fine with one
exception. What I really like to do is stop copying the formula if
there is no values in Column A, in other word do copy until cell in
Column A is Null, Starting from A3.

Range("C2:BL2").Select
Selection.AutoFill Destination:=Range("C2:BL43"),
Type:=xlFillDefault
Range("C2:BL43").Select

A B C D E F Etc -----------
1 NAME Formula Formula Formula
2 Name


Ardy


Dave Peterson

Don't Copy If Null -- Help
 
Can you start at the bottom of column A and come up to find that last used cell?

dim LastRow as long
with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row
.range("c2:bl2").autofill destination:=.range("c2:bl" & lastrow), _
type:=xlfilldefault
end with

Ardy wrote:

I have generated a code with help of macro's that will select a range
and then Auto fills it to a given range. It all works fine with one
exception. What I really like to do is stop copying the formula if
there is no values in Column A, in other word do copy until cell in
Column A is Null, Starting from A3.

Range("C2:BL2").Select
Selection.AutoFill Destination:=Range("C2:BL43"),
Type:=xlFillDefault
Range("C2:BL43").Select

A B C D E F Etc -----------
1 NAME Formula Formula Formula
2 Name

Ardy


--

Dave Peterson

Ardy

Don't Copy If Null -- Help
 
Peter:

The Problem is that I am inserting the first row of the formula to
transfer some data points from other Tabs to C2:BL2 , Then Copying via
Auto fill from C3:BL3 until I see a Null in Column A Starting from A3,
So I really need to start from top until I see Null In Column A then
Stop

Sorry I responded late X-mas Stuff.....

Ardy

Dave Peterson wrote:
Can you start at the bottom of column A and come up to find that last used cell?

dim LastRow as long
with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row
.range("c2:bl2").autofill destination:=.range("c2:bl" & lastrow), _
type:=xlfilldefault
end with

Ardy wrote:

I have generated a code with help of macro's that will select a range
and then Auto fills it to a given range. It all works fine with one
exception. What I really like to do is stop copying the formula if
there is no values in Column A, in other word do copy until cell in
Column A is Null, Starting from A3.

Range("C2:BL2").Select
Selection.AutoFill Destination:=Range("C2:BL43"),
Type:=xlFillDefault
Range("C2:BL43").Select

A B C D E F Etc -----------
1 NAME Formula Formula Formula
2 Name

Ardy


--

Dave Peterson



Dave Peterson

Don't Copy If Null -- Help
 
Maybe you could use:

lastrow = .cells(1,"A").end(xldown).row



Ardy wrote:

Peter:

The Problem is that I am inserting the first row of the formula to
transfer some data points from other Tabs to C2:BL2 , Then Copying via
Auto fill from C3:BL3 until I see a Null in Column A Starting from A3,
So I really need to start from top until I see Null In Column A then
Stop

Sorry I responded late X-mas Stuff.....

Ardy

Dave Peterson wrote:
Can you start at the bottom of column A and come up to find that last used cell?

dim LastRow as long
with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row
.range("c2:bl2").autofill destination:=.range("c2:bl" & lastrow), _
type:=xlfilldefault
end with

Ardy wrote:

I have generated a code with help of macro's that will select a range
and then Auto fills it to a given range. It all works fine with one
exception. What I really like to do is stop copying the formula if
there is no values in Column A, in other word do copy until cell in
Column A is Null, Starting from A3.

Range("C2:BL2").Select
Selection.AutoFill Destination:=Range("C2:BL43"),
Type:=xlFillDefault
Range("C2:BL43").Select

A B C D E F Etc -----------
1 NAME Formula Formula Formula
2 Name

Ardy


--

Dave Peterson


--

Dave Peterson

Ardy

Don't Copy If Null -- Help
 
Peter:
I am Sorry...... IIt works just as same from the bottom, I didn't
think It Would. This was so Easy...

Thanks
Ardy wrote:
Peter:

The Problem is that I am inserting the first row of the formula to
transfer some data points from other Tabs to C2:BL2 , Then Copying via
Auto fill from C3:BL3 until I see a Null in Column A Starting from A3,
So I really need to start from top until I see Null In Column A then
Stop

Sorry I responded late X-mas Stuff.....

Ardy

Dave Peterson wrote:
Can you start at the bottom of column A and come up to find that last used cell?

dim LastRow as long
with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row
.range("c2:bl2").autofill destination:=.range("c2:bl" & lastrow), _
type:=xlfilldefault
end with

Ardy wrote:

I have generated a code with help of macro's that will select a range
and then Auto fills it to a given range. It all works fine with one
exception. What I really like to do is stop copying the formula if
there is no values in Column A, in other word do copy until cell in
Column A is Null, Starting from A3.

Range("C2:BL2").Select
Selection.AutoFill Destination:=Range("C2:BL43"),
Type:=xlFillDefault
Range("C2:BL43").Select

A B C D E F Etc -----------
1 NAME Formula Formula Formula
2 Name

Ardy


--

Dave Peterson



Dave Peterson

Don't Copy If Null -- Help
 
Dave.

Ardy wrote:

Peter:
I am Sorry...... IIt works just as same from the bottom, I didn't
think It Would. This was so Easy...

Thanks
Ardy wrote:
Peter:

The Problem is that I am inserting the first row of the formula to
transfer some data points from other Tabs to C2:BL2 , Then Copying via
Auto fill from C3:BL3 until I see a Null in Column A Starting from A3,
So I really need to start from top until I see Null In Column A then
Stop

Sorry I responded late X-mas Stuff.....

Ardy

Dave Peterson wrote:
Can you start at the bottom of column A and come up to find that last used cell?

dim LastRow as long
with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row
.range("c2:bl2").autofill destination:=.range("c2:bl" & lastrow), _
type:=xlfilldefault
end with

Ardy wrote:

I have generated a code with help of macro's that will select a range
and then Auto fills it to a given range. It all works fine with one
exception. What I really like to do is stop copying the formula if
there is no values in Column A, in other word do copy until cell in
Column A is Null, Starting from A3.

Range("C2:BL2").Select
Selection.AutoFill Destination:=Range("C2:BL43"),
Type:=xlFillDefault
Range("C2:BL43").Select

A B C D E F Etc -----------
1 NAME Formula Formula Formula
2 Name

Ardy

--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 05:07 PM.

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