ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copy until certain condition (https://www.excelbanter.com/excel-programming/397227-copy-until-certain-condition.html)

AlanW

copy until certain condition
 
I would like to copy B1 to B2:B1000 until a cell in Column A is empty by
using VBA. Could someone please help.

Thanks

OssieMac

copy until certain condition
 
Hi Alan,

I am not certain that I understand exactly what you want to do because your
description is a little vague.

I interpret your request as you want to copy cell B1 and paste the contents
down in column B until it comes to a blank cell in column A. If this is right
then you can use the following:-

With Sheets("Sheet1")
.Range("B1").Copy _
Destination:=.Range(.Cells(2, 1) _
.End(xlDown).Offset(0, 1), .Cells(2, 2))
End With

You may replace the line With Sheets("Sheet1") with the following line if it
will always be the active sheet:-

With ActiveSheet

If my interpretation is not correct then please reply and I'll have another
go at it.

Regards,

OssieMac





"AlanW" wrote:

I would like to copy B1 to B2:B1000 until a cell in Column A is empty by
using VBA. Could someone please help.

Thanks


AlanW

copy until certain condition
 
Hello OssieMac,

That's what I want to do, many Thanks

Alan
"OssieMac" wrote:

Hi Alan,

I am not certain that I understand exactly what you want to do because your
description is a little vague.

I interpret your request as you want to copy cell B1 and paste the contents
down in column B until it comes to a blank cell in column A. If this is right
then you can use the following:-

With Sheets("Sheet1")
.Range("B1").Copy _
Destination:=.Range(.Cells(2, 1) _
.End(xlDown).Offset(0, 1), .Cells(2, 2))
End With

You may replace the line With Sheets("Sheet1") with the following line if it
will always be the active sheet:-

With ActiveSheet

If my interpretation is not correct then please reply and I'll have another
go at it.

Regards,

OssieMac





"AlanW" wrote:

I would like to copy B1 to B2:B1000 until a cell in Column A is empty by
using VBA. Could someone please help.

Thanks



All times are GMT +1. The time now is 02:14 AM.

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