VBA code export selected columns

jaaimee

New Member
Joined
Nov 8, 2018
Messages
16
Hi everyone,

Is there any VBA code that allows me to make use of a userform and it will populate a new excel file with the headers selected?

Screen-Shot-2018-02-05-at-11.15.31-AM-600x367.png


It will look and work like the picture above, where the different check boxes are linked to the different columns (headers) and user get to choose which headers they want to export. And when they clicked on a button, a new excel file with the selected headers will be created.

Any help is greatly appreciated! I do hope to get some directions to start off with this.
Thank you so much in advance!

Jaime :)
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
This can be done, firsts question have you named each checkbox when you created the userform (I am hoping via the VBA screen). If yes what names are you using (only need 4 in reply just to get the code going so you can see what to do).
 
Upvote 0
Hi, thanks for the reply. The names will be the headers inside the excel sheet.
A few examples will be Equipment Type, Floor, Room Name, Local Motor Control Panel.
 
Upvote 0
Not what I was asking, what names are being used on the checkboxes in the userform. Usually the defaults are CheckBox1 or CheckBox2 etc, have you renamed them to something more recognisable like chkEquipmentType, chkFloor, chkRoomName, chkLocalMotorControlPanel, this would then provide how to match the columns they will select to make the new worksheet.
 
Upvote 0
Oops, sorry!
I did not rename them yet, all of them remained at the default naming.
However, i plan to change them to something similar to the headers' name.

1. CEqType
2. CFloor
3. CRmName
4. CLMCP
 
Upvote 0
Is each checkbox linked to a specific cell in the sheet. i.e Equipment Type is Cell A1,
Floor is Cell C1,
Room Name is Cell D1 etc it doesn't matter if the column examples I am suggesting is correct but that they are linked to the first cell in the column.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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