This question may be easy to answer

ColdGeorge

Active Member
Joined
Aug 21, 2012
Messages
412
Office Version
  1. 2016
Platform
  1. Windows
Hi all

I just want to copy a cell (A1) value down to A2. Only if B2 has a value. And so forth, copy A2 to A3 if B3 has a value.

Thanks in advance, ColdGeorge
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Try

Code:
With Range("A1", Cells(Range("B65536").End(xlUp).Row-1, 1)
    .Copy Destination:= .Offset(1,0)
End With
 
Last edited:
Upvote 0
Hi mikerickson

I'll give it a try and I'll let yoo know, thanks.

ColdGeorge
 
Upvote 0
Hi mikerickson

I am very sorry, but I'm afraid I made a big mistake due to my poor English. I want to copy A1 value to all cells of column A. Only if column B cells have a value. In another words stop the copying procedure when an empty cell in column B is found.

Thanks, ColdGeorge
 
Upvote 0
Code:
Sub test()
    Dim i As Long
    i = 0
    With Range("A1")
        Do Until .Offset(i + 1, 1) = vbNullString
            i = i + 1
        Loop
        .Offset(1, 0).Resize(i, 1).Value = .Value
    End With
End Sub
 
Upvote 0
Hi mikerickson

I am very sorry, but I'm afraid I made a big mistake due to my poor English. I want to copy A1 value to all cells of column A. Only if column B cells have a value. In another words stop the copying procedure when an empty cell in column B is found.

Thanks, ColdGeorge


Try...

=IF(B2<>"",$A$1,"")


Explanation: IF B2 contains text OR number, print A1, otherwise, print nothing.


Ps. Im brand new, so use caution when taking my advise. If it did help you, dont forget to "Thank you for posting this" and or "Like this post" :biggrin:
 
Upvote 0
mikerickson

Thanks, your code works just perfect.


BrandonBerner

Your formula, works great too, thanks.


ColdGeorge
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,161
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top