Updating cells based on another

KW

Board Regular
Joined
Jan 25, 2005
Messages
167
I have a spreadsheet with various dates as shown below

Col V Col W Col X Col Y
26-Feb-09 1 26-Mar-09 1
01-Feb-09 12 01-Feb-10 0
27-Feb-09 1 27-Mar-09 1
19-Feb-09 3 19-May-09 0
20-Feb-09 3 20-May-09 0

I want to replace the date in Col V with the date in Col X when Col Y = '1'. As Col X contains a formulae, I only want to be able to copy and the cell value.

I've tried filtering Col Y for '1', but as the resulting cells are non-adjacent, I can't copy and paste the resulting selection. Perhaps a simple macro might work, but I could really do with some guidance.

Regards

KW
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Think this should do :

Code:
Sub UpdateDate()

Dim LRow As Long

LRow = Application.Range("X65536").End(xlUp).Row

For i = 2 To LRow

    If Range("Y" & i).Value = 1 Then
        Range("X" & i).Copy
        Range("V" & i).PasteSpecial (xlValues)
    End If

Next

MsgBox "Done !"

End Sub


Hope this helps !
 
Upvote 0

Forum statistics

Threads
1,214,954
Messages
6,122,462
Members
449,085
Latest member
ExcelError

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