Drop boxes with a Macro to copy

helpexcel

Well-known Member
Joined
Oct 21, 2009
Messages
656
I am creating a spreadsheet that has drop boxes at the top of each column that has a "Yes/No" option. If the column has a "yes" i want it pasted to another worksheet, while the "No" column's are skipped. I have inserted a menu button that when clicked, will run the macro and paste all the yes columns.

Thanks for the help and direction.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Something like this, assuming your Yes/No's are in the first row.

Code:
Option Explicit

Sub CopyColumns()

Dim cel As Range
Dim wksSource, wksDestination As Worksheet
Dim count As Long

Set wksSource = ActiveSheet
Set wksDestination = wksSource.Parent.Worksheets.Add

count = 1

For Each cel In wksSource.[1:1]

    If cel = "Yes" Then
        cel.EntireColumn.Copy wksDestination.Cells(1, count)
        count = count + 1
    End If
        
Next cel
End Sub
 
Upvote 0
That works great, thanks.

If I want to copy to an existing sheet, I tried using Set wksDestination = Sheets("Yes") but no luck. Also can no luck with using Sheets("list").Select for the selecting the active sheet.

I was able to change the rows, but how do I remove row 1 so the "yes" doesn't show?
 
Upvote 0

Forum statistics

Threads
1,214,618
Messages
6,120,544
Members
448,970
Latest member
kennimack

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