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

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
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,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

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