Vlookup Macro to fill several cells

EdGilmore

New Member
Joined
Mar 25, 2011
Messages
12
Hi,

I'm trying to write a macro that will automatically fill several cells with information located on a different sheet of a workbook. I could do this manually using the vlookup function, however I want to do it via a macro so it can be done using a click button.

The principal is as follows:

Sheets labelled "Submission" and "Data"

A reference number is typed into cell C2 of "Submission"

I want this to Vlookup "Data" and return values on that sheet into cells C4-C8 of "Submission". The vlookup would return the following values:

C4 - "Data" column B

C5 - "Data" column C

C6 - "Data" column D

C7 - "Data" column E

C8 - "Data" column F

The column to lookup in "Data" is column A.

The Vlookup I am currently using for cell C4 is:

=vlookup(C2,Data!A:B,2,FALSE)

And so on.

Any ideas?
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
In your macro, that in put the formula you want in each of the top cells, then copy and paste it down. You could copy/paste special/values afterwards so the numbers can't change.
 
Upvote 0
Thanks cjcobra. VB code isn't exactly my strong suit, any chance you could show me how it would look in VB?
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,917
Members
452,949
Latest member
beartooth91

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