If Value is Entered, opy paste into other column

coach_veto

New Member
Joined
Jan 26, 2016
Messages
15
Hi guys,

I have two columns and I am trying to find the best way to write a change driven code that will accomplish my goal.

If a value is entered into column A, then that value is copy/pasted into column D in the same row if that cell in column D is empty. Column D should be able to be overridden once a value is pasted in their. I need this code to apply to multiple rows in both columns. (for example: A1:A1000 and D1:D1000) The value entered in column A/row 1 should match column D/row 1 and so on once the code is executed.

Also, the columns are not right next to each other if that helps.

Thanks!
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Code:
Sub k1()
For i = 1 To 1000
If Cells(i, 1) <> "" And Cells(i, 4) = "" Then Cells(i, 4) = Cells(i, 1)
End If
Next i
End Sub
 
Last edited:
Upvote 0
Hi coach_veto,

If i am understanding you correctly, when you say change driven code you mean when you enter a value in a cell in A1:A1000, it's value automatically copies to column D of the same row (so long as there was not already a value in column D).

If that is correct, try this out in a COPY of your workbook. Right-click on the tab name of the sheet and select View Code, before copy / pasting in the following:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A1:A1000")) Is Nothing Then
        If Range("D" & Target.Row).Value = "" Then
            Range("D" & Target.Row).Value = Target.Value
        End If
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,432
Members
452,326
Latest member
johnshaji

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