Drop down list loop, copy and paste updated values from a worksheet to a new workbook.

nitishbanka

New Member
Joined
Oct 17, 2018
Messages
2
Hi, I have never used VBA before.

I am trying to automate a process for which I have created a simple example to get help.

I have a drop down list in Sheet1, Cell "A3" with values 1, 2 and 3.
The values in Sheet 2, Range B3:B5 forms accordingly.
The formulas used in Sheet2 are as follows:
B3: =IF(B4=5,"Base",IF(B4=10,"Scenario 1","Scenario 2"))
B4: =Sheet1!A3*5
B5: =Sheet1!A3*10

Now what I want is for Sheet1 drop down to run on a loop and the entire updated Sheet2 along with all formats to get copied in a new workbook.

I also wanted the name of the Sheet in the new workbook to be whatever the value is in Sheet2, Cell B3 (Base, Scenario 1 and Scenario 2).

This is a recurring activity with much larger data and I could really use the help of a VBA code.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Cross posted https://www.excelforum.com/excel-pr...alues-from-a-worksheet-to-a-new-workbook.html

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
@ravishankar
Please post any code/formulae to the thread, rather than just uploading a workbook. As per Rule#4
 
Upvote 0
Ravi
Pleas post you solution as requested.
 
Upvote 0
right click on sheet1 and choose view code and paste the following
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A3")) Is Nothing Then
x = Application.WorksheetFunction.VLookup(Range("A3"), Range("I2:J4"), 2, False)
MsgBox x
y = Sheets("sheet2").Cells(Rows.Count, 1).End(xlUp).Row
Sheets("sheet2").Cells(y + 1, 1) = x
End If
End Sub
In cell I2, paste the following table (2 columns and 3 rows)
[TABLE="width: 136"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD="align: right"]1 [/TD]
[TD]Base[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD] Scenario-1[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD]Scenario-2[/TD]
[/TR]
</tbody>[/TABLE]
When you change cell A3, macro runs and lists it in sheet2. OP's need is not clear. More features can be added if so wanted.
ravi shankar
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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