Consulting

Results 1 to 5 of 5

Thread: Drop Down List to Copy Contents of Another Column into a Certain Column

  1. #1
    VBAX Regular
    Joined
    Jul 2012
    Posts
    50
    Location

    Drop Down List to Copy Contents of Another Column into a Certain Column

    I am looking to implement a drop down menu in which you select A (column H), B (column I), or C (column J) and it fills the values listed in each corresponding column (from the selection) into column F. Furthermore, if the column selected as no value, then it would retain what is already listed in column F. So in the screen shot, if A (column H) were selected from the list, then 03, 04 would be retained as this is blank in the column but 00 would be copied over. So we would have 04, 04, 00, 06, 07, 08, 05, 06, 07,.. in column F. Any suggestions on implantation?
    Attached Images Attached Images
    • File Type: jpg 1.JPG (30.9 KB, 5 views)

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Did you want to copy the cell with includes formatting, or did you want to just insert the value?

    If you would post an example workbook, it is easier to help you.

  3. #3
    VBAX Regular
    Joined
    Jul 2012
    Posts
    50
    Location
    I would just want to insert the value and retain the value for certain cells. In the workbook I have posted H7, H11, H12, H13,.. the cells in the H column which have values would retain those. Then depending on the selection of A, B, or C (Column J, K, & L) from a drop down window, the contents would be inserted for the other cells. So if A was selected then J7 would be inserted into H7, J11 would be inserted to H11, ....
    Attached Files Attached Files

  4. #4
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    1. Select J4:L4 and Name it myList.
    2. Select H4 and make the Data > Data Validation > Data Validataion > List, =myList.
    3. Right click that sheet's tab > View Code, and paste:
    [VBA]Private Sub Worksheet_Change(ByVal Target As Range)
    Dim r As Range, c As Range

    Set r = Intersect(Target, Range("H4"))
    If r Is Nothing Then Exit Sub

    Set r = Range("myList").Find(r.Value2)
    If r Is Nothing Then Exit Sub

    Set r = Range(r.Offset(1), Cells(Rows.Count, r.Column).End(xlUp))
    Application.EnableEvents = False
    For Each c In r
    If IsEmpty(Range("H" & c.Row)) Then Range("H" & c.Row).Value = c.Value
    Next c
    Application.EnableEvents = True
    End Sub[/VBA]

  5. #5
    VBAX Regular
    Joined
    Jul 2012
    Posts
    50
    Location
    I was able to figure it out and get it working using data validation and formulas, thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •