Copy date of a cell if a value is repeated

zargon

New Member
Joined
May 4, 2017
Messages
10
Hi I hope you can help me.

I have a sheet that contains 3 columns, Label, Chip and Date, the label column can contain duplicate data if this occurs i need copy this date in the next row that contains the same label.

Example:
Label Chip Date
133 9871452 09/05/17
133 8971453
133 9875488
134 7899984 10/05/17
134 7899875
135 8798458 11/05/17
135 8798458


Result:

Label Chip Date
133 9871452 09/05/17
133 8971453 09/05/17
133 9875488 09/05/17
134 7899984 10/05/17
134 7899875 10/05/17
135 8798458 11/05/17
135 7895412 11/05/17
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Formula
D2 =IF(C2<>"",C2,D1)
copy to down.
Paste values columnD to columnC.

macro
Code:
Sub test()
Dim LR As Long, i As Long, buf
LR = cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To LR
    If cells(i, 3).Value <> "" Then
        buf = cells(i, 3).Value
    Else
        cells(i, 3).velue = buf
    End If
Next
End Sub
 
Upvote 0
Thank you so much Takae, very cool... i hope not to bother i tried to implement a solution with your macro but i am rookie...

Well the real format is like this:
V
W
X
Y
Z
AA
AB
AC
AD
AE
AF
3
ID
LABEL
DAT 1
DAT 2
DAT 3
DAT 4
DAT 5
DAT 6
DAT 7
DAT 8
4
1330102
10171
12:02
12:08
13:00
14:24
14:40
15:30
16:28
04:20
5
1329807
9598
11:57
12:20
13:05
14:10
14:22
15:02
15:35
03:15
6
1329807
9598
7
1329807
9598
8
1331864
9608
15:49
16:02
16:12
17:13
17:25
18:56
19:14
03:12
9
1329708
9608
10
5001027
98327
13:30
13:22
13:32
14:09
14:19
14:54
15:13
01:51
11
1307566
98327
12
1306925
98327
13
1307574
98327

<tbody>
</tbody>

and i need this:


V
W
X
Y
Z
AA
AB
AC
AD
AE
AF
3
ID
LABEL
DAT 1
DAT 2
DAT 3
DAT 4
DAT 5
DAT 6
DAT 7
DAT 8
4
1330102
10171
12:02
12:08
13:00
14:24
14:40
15:30
16:28
04:20
5
1329807
9598
11:57
12:20
13:05
14:10
14:22
15:02
15:35
03:15
6
1329807
9598
11:57
12:20
13:05
14:10
14:22
15:02
15:35
03:15
7
1329807
9598
11:57
12:20
13:05
14:10
14:22
15:02
15:35
03:15
8
1331864
9608
15:49
16:02
16:12
17:13
17:25
18:56
19:14
03:12
9
1329708
9608
15:49
16:02
16:12
17:13
17:25
18:56
19:14
03:12
10
5001027
98327
13:30
13:22
13:32
14:09
14:19
14:54
15:13
01:51
11
1307566
98327
13:30
13:22
13:32
14:09
14:19
14:54
15:13
01:51
12
1306925
98327
13:30
13:22
13:32
14:09
14:19
14:54
15:13
01:51
13
1307574
98327
13:30
13:22
13:32
14:09
14:19
14:54
15:13
01:51

<tbody>
</tbody>


Hope you can help me.

P.S. Sorry for the bad format.
 
Last edited:
Upvote 0
With the next modify i can get result in the Y column, now i have a question...

Sub test()
Dim LR As Long, i As Long, buf
LR = Cells(Rows.Count, 2).End(xlUp).Row
For i = 3 To LR
If Cells(i, 25).Value <> "" Then
buf = Cells(i, 25).Value
Else
Cells(i, 25).Value = buf
End If
Next
End Sub

How i can copy the same data to the Z, AA, AB, AC, AD, AE columns?
 
Upvote 0
modified code as follows.
Hope this helps.

Code:
Sub test()
Dim LR As Long, i As Long, buf
LR = cells(Rows.Count, 23).End(xlUp).Row
For i = 4 To LR
    If cells(i, 25).Value <> "" Then
        buf = Range(cells(i, 25), cells(i, 32))
    Else
        Range(cells(i, 25), cells(i, 32)) = buf
    End If
Next
 Range(Range("Y3"), cells(LR, 32)).NumberFormatLocal = "h:mm;@"
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,694
Messages
6,126,258
Members
449,307
Latest member
Andile

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