autofill column based on a different column

tcy0330

New Member
Joined
Jul 24, 2012
Messages
9
Hi,

I have a macro I (with a ton of help) wrote a while ago to auto fill a column based on a value in another column. Here it is:

ElseIf Not Intersect(Target, Columns("C")) Is Nothing Then
Dim tmp As Range
Set tmp = Sheets("Client No List").Range("A2:A1500").Find(Target.Value)
If Not tmp Is Nothing Then
Target.Offset(0, 1).Value = tmp.Offset(0, 1).Value
Else
Target.Offset(0, 1).Value = "???"
End If
End If
End Sub

Originally this was written where the column I wanted to automatically fill based on the value in column C was column D (and it works). D has since moved over 1 spot, and is now Column E. So, what do I need to change in the formula so that the proper value is entered into column E based on value in column C?

Thanks in advance,
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Your macro has a conditional such that the Target (the cell you change) is in column C with:
ElseIf Not Intersect(Target, Columns("C")) Is Nothing Then
Which means the cell must be in column C.

So the range you want to copy to is the Target with an offset. Previously, you offset by 1 (from C to D), but now you want to offset by 2 (from C to E) so change:
Target.Offset(0, 1).Value = tmp.Offset(0, 1).Value

To this line:
Target.Offset(0, 2).Value = tmp.Offset(0, 1).Value




And also your "???" message needs to be moved over too. Change:
Target.Offset(0, 1).Value = "???"

To:
Target.Offset(0, 2).Value = "???"



Hope this helps!
 
Upvote 0
I was just coming on to post that I had figured this out! But thank you for the help, regardless. Much appreciated.

Best
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,457
Members
449,083
Latest member
Ava19

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