VBA - lookup and replace

aheverett1

New Member
Joined
May 23, 2017
Messages
16
I'm stuck on a problem in VBA. I need to replace a current light fixture in a cell with another light fixture and then loop to the next cell down and do the same until either a blank cell or the end of my range. The fixture that replaces the current is in a "datasheet" and is in the same row as the current fixture, just a different column. I can currently just do a vlookup and get what the replacement fixture is going to be but i'm not sure how to lookup the current fixture in column A and replace it with the fixture in column G using VBA. The column the replacement fixture is in would be determined by another cell as well.

if this is too vague i am happy to expand more on it.

Thank you in advance.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
if i understand correlty try this on a copy of your file.

Code:
Sub do_it()

For r = 2 To 100 'adjust range as needed
Cells(r, "A").Value = Worksheets("Datasheet").Cells(r, "G").Value
Next r

End Sub

hth,
Ross
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

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