Solved

valuelist value to assign variables to colums in different sheets

Posted on 2013-11-21
3
180 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
  • 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
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.

705 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now