Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

valuelist value to assign variables to colums in different sheets

Posted on 2013-11-21
3
Medium Priority
?
237 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

916 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