Solved

valuelist value to assign variables to colums in different sheets

Posted on 2013-11-21
3
219 Views
Last Modified: 2013-11-22
folks

sheet 1

column 2        column b
uk                  london
usa                 wash dc
france               paris

i need a valuelist when selecting a value from colum a then it will write  the selected value
from colum a to sheet 2 column a 5 times and write the corresponding colum b value 10 times to sheet 3

any ideas? i have attached the output requirement on excel for further explanation
sheet-valuelist.xlsx
0
Comment
Question by:rutgermons
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39668142
How do you intend to "Select" a value from column A? Do you just put the cursor on the value?
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39668154
If you want to place the cursor on the value then
You can use this code in the worksheet module

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Column = 1 Then
        Sheet2.Range("A2").Resize(5).Value = Target.Value
        Sheet3.Range("A2").Resize(10).Value = Target.Offset(, 1).Value
    End If
End Sub

Open in new window


To use the code
Right-click on the sheet tab name
Select View code
Paste this code in the VBA window
Close the VBA window
0
 
LVL 22

Accepted Solution

by:
Flyster earned 500 total points
ID: 39668175
See Combobox on sheet1. This code is used to populate it:
Private Sub ComboBox1_GotFocus()
Dim r As Long

r = Sheet1.Range("A1").Offset(Sheet1.Rows.Count - 1, 0).End(xlUp).Row
    With ComboBox1
        .ColumnCount = 2
        .List = Range("A2:B" & r).Value
    End With

End Sub

Open in new window

If more locations are added, they will appear in the combobox.
Flyster
sheet-valuelist-Combobox.xlsm
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question