Copy cell If not Null

Lutsch

New Member
Joined
Feb 3, 2011
Messages
4
I have 3 columns I want a vb code to copy cell from b to adjacent cell c if b is not null -- B3 = 24 then copy and paste b3 to c3

Thanks
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
A formula will do this for you, ie: =IF(B3="",B3,"")
Place formula in cell C3 and copy down.

If you must use VBA, the try this:

Sub CopyVals()
Dim intLastRow As Integer
intLastRow = ActiveSheet.Range("A65536").End(xlUp).Row

For Each c In Range("A1:A" & intLastRow)
If c.Value <> "" Then
c.Offset(0, 1).Value = c.Value
End If
Next c
End Sub
 
Upvote 0
Does it HAVE to be a macro?

You do know (right?) that you can enter the formula =B3 into cell C3 and C3 will return whatever is in cell B3. (0 if B3 is blank, 24 if B3 is 24, etc.)

EDIT:
If you really do need code for this it's easy to do, we just need to know the entire range of interest.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,854
Members
452,948
Latest member
UsmanAli786

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