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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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,213,563
Messages
6,114,329
Members
448,564
Latest member
ED38

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