Copy data from one sheet to another based on Drop-Down box selection

earwig999

New Member
Joined
Jan 11, 2013
Messages
42
Not sure how to explain this but here goes.

I have a workbook containing 2 sheets. On sheet 2 I have a drop down (select from list) which allows you to choose a month.

On sheet 1 I have the full list of data relating to Jan - Dec.

What I want to do is if I select eg. January from the drop down box on sheet 2, then copy the data selected from under the January section of sheet 1 to a section on sheet 2.

Is this possible, and if so how please?

(Would I have to create ranges in sheet 1 for each month and then somehow get that range to copy over to sheet 2 based on the drop down selection?)
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Trying to add another elseif but yet again it doesn't want to work.

I'm sure I must have missed something but can't see the wood for the trees!

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("K1,K40")) Is Nothing Then Exit Sub
    
    If Target.Address = "$K$1" Then
        Select Case Target.Value
            Case "January"
                Sheets("Input").Range("B8:H24").Copy Sheets("Power").Range("B6")
            Case "February"
                Sheets("Input").Range("I8:O24").Copy Sheets("Power").Range("B6")
            Case "March"
                Sheets("Input").Range("P8:V24").Copy Sheets("Power").Range("B6")
            Case "April"
                Sheets("Input").Range("W8:AC24").Copy Sheets("Power").Range("B6")
            Case "May"
                Sheets("Input").Range("AD8:AJ24").Copy Sheets("Power").Range("B6")
            Case "June"
                Sheets("Input").Range("AK8:AQ24").Copy Sheets("Power").Range("B6")
            Case "July"
                Sheets("Input").Range("AR8:AX24").Copy Sheets("Power").Range("B6")
            Case "August"
                Sheets("Input").Range("AY8:BE24").Copy Sheets("Power").Range("B6")
            Case "September"
                Sheets("Input").Range("BF8:BL24").Copy Sheets("Power").Range("B6")
            Case "October"
                Sheets("Input").Range("BM8:BS24").Copy Sheets("Power").Range("B6")
            Case "November"
                Sheets("Input").Range("BT8:BZ24").Copy Sheets("Power").Range("B6")
            Case "December"
                Sheets("Input").Range("CA8:CG24").Copy Sheets("Power").Range("B6")
        
        End Select
        
     ElseIf Target.Address = "$K$40" Then
        Select Case Target.Value
            Case "January"
                Sheets("Input").Range("P51:R68").Copy Sheets("Power").Range("L46")
            Case "February"
                Sheets("Input").Range("S51:U68").Copy Sheets("Power").Range("L46")
            Case "March"
                Sheets("Input").Range("V51:X68").Copy Sheets("Power").Range("L46")
            Case "April"
                Sheets("Input").Range("Y51:AA68").Copy Sheets("Power").Range("L46")
            Case "May"
                Sheets("Input").Range("AB51:AD68").Copy Sheets("Power").Range("L46")
            Case "June"
                Sheets("Input").Range("AE51:AG68").Copy Sheets("Power").Range("L46")
            Case "July"
                Sheets("Input").Range("AH51:AJ68").Copy Sheets("Power").Range("L46")
            Case "August"
                Sheets("Input").Range("AK51:AM68").Copy Sheets("Power").Range("L46")
            Case "September"
                Sheets("Input").Range("AN51:AP68").Copy Sheets("Power").Range("L46")
            Case "October"
                Sheets("Input").Range("AQ51:AS68").Copy Sheets("Power").Range("L46")
            Case "November"
                Sheets("Input").Range("AT51:AV68").Copy Sheets("Power").Range("L46")
            Case "December"
                Sheets("Input").Range("AW51:AY68").Copy Sheets("Power").Range("L46")
        End Select
    
               
    ElseIf Target.Address = "$K$116" Then
        Select Case Target.Value
            Case "January"
                Sheets("Input").Range("B123:I134").Copy Sheets("Power").Range("B121")
            Case "February"
                Sheets("Input").Range("J123:Q134").Copy Sheets("Power").Range("B121")
            Case "March"
                Sheets("Input").Range("R123:Y134").Copy Sheets("Power").Range("B121")
            Case "April"
                Sheets("Input").Range("Z123:AG134").Copy Sheets("Power").Range("B121")
            Case "May"
                Sheets("Input").Range("AH123:AO134").Copy Sheets("Power").Range("B121")
            Case "June"
                Sheets("Input").Range("AP123:AW134").Copy Sheets("Power").Range("B121")
            Case "July"
                Sheets("Input").Range("AX123:BE134").Copy Sheets("Power").Range("B121")
            Case "August"
                Sheets("Input").Range("BF123:BM134").Copy Sheets("Power").Range("B121")
            Case "September"
                Sheets("Input").Range("BN123:BU134").Copy Sheets("Power").Range("B121")
            Case "October"
                Sheets("Input").Range("BV123:CC134").Copy Sheets("Power").Range("B121")
            Case "November"
                Sheets("Input").Range("CD123:CK134").Copy Sheets("Power").Range("B121")
            Case "December"
                Sheets("Input").Range("CL123:CS134").Copy Sheets("Power").Range("B121")
        End Select
    
    End If
           
    End Sub

*** Edit - Sorry me again. I found it, I hadn't referenced the new Target Range at the beginning of the code. :)

At least I'm learning and finding it myself!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,590
Members
449,039
Latest member
Arbind kumar

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