Using the data in a cell as a worksheet reference in vba

Yeoman.jeremy

Board Regular
Joined
Apr 4, 2011
Messages
90
Hi there,
I've created in my workbook a simple sheet to help the users input new products into the system (as opposed to them going into the different worksheet where there are formulas)

It has a cell with a validated list of all the different suppliers (also the name of the sheets for each supplier's products). also cells with: the product name, cost, price etc etc etc

Once all this data has been entered into the cells, they press a command button, which will look at the supplier name, and enters the information to their relative cells in the appropriate sheet.

How can I code it to duplicate the information to the sheet with the same name as the information in the cell?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Simple code (here, A2 is the cell with the dropdown, and the "master" sheet the user inputs information on is Sheet1. This code inserts the value from the dropdown list into A1 in whichever sheet is selected from the dropdown. But you can make it insert what ever you need it to. Let me know if you have further questions regarding how to input other information...

Code:
Sub Button1_Click()
 Sheets(Range("A2").value).Range("A1")=Sheets("Sheet1").Range("A2").value
End Sub
 
Upvote 0
Hi again,

Just realised another complication, which yoiu'll probably be able to solve in a split second :laugh:

There is a large list of the products on this page, is there a way for the destination cell to be the next cell in the column that doesn't have anything in it?

Cheers
 
Upvote 0
Try a version of this:

Code:
        Sheets(Range("A2").Value).Range("A1").Select
        Selection.End(xlDown).Select
        ActiveCell.Offset(1, 0).Select
        ActiveCell.Value = Sheets("Sheet1").Range("A2")

If that doesn't work for you, try removing the third line...I don't know exactly how your sheets are set up...
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

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