PDA

View Full Version : VBA: Selecting and Copying Columns [more complex than it sounds]



jlkamikaze
09-08-2011, 08:59 AM
okay so long story short is i need to transfer data from one excel sheet into another :help

here is the scenario that i have if somebody could tell me if its possible/feasible or if there is another way to do so...

there are a number of columns with data organized by headers [Weight, Mass, Height, Color, etc.]

the user SELECTS a certain number of rows [say rows 2, 4, and 7]

the user is then prompted for which pieces of data should be copied for ALL of these rows... whether this be through a checklist or drop down menu or anything organized

for example, i would choose the Weight and Mass of rows 2, 4, and 7
to be transferred into a new sheet with only the data for rows 2, 4, and 7 and their Weight and Mass

is this possible? any help, suggestions, pointers, or solutions would be greatly appreciated. thank you in advance! :hi:

Kenneth Hobs
09-08-2011, 09:29 AM
I don't know why you started another thread. http://www.vbaexpress.com/forum/showthread.php?p=250123

In that other thread, you need to post an example so that you can get more help. You need to decide on a method for selecting columns. You could just Select the cells though which is easy and skips the need for a column selection. There are several methods to pick the columns to select. A Listbox with checkbox items would seem easy enough. A Userform is probably the best route. The Userform would be shown or set as modeless to allow selection of rows.

jlkamikaze
09-08-2011, 09:51 AM
how do you go about creating a Listbox or Userform? this system would be less for small sets of data and more for large sets instead where picking out the cells individually would be a hassle and also pasting them into a new sheet one by one

JKwan
09-08-2011, 10:47 AM
Try this out

jlkamikaze
09-08-2011, 11:35 AM
thats perfect! how did you implement the checkboxes??

JKwan
09-08-2011, 11:39 AM
easiest, just put the spreadsheet into DESIGN mode and do a copy and paste - making sure they are in sequential order! Otherwise, the wrong column will be selected and your destination will get screwed up.

jlkamikaze
09-08-2011, 11:56 AM
thank you to both of you!

jlkamikaze
09-09-2011, 06:21 AM
last question @JKwan: is there anyway to put that [or something like it] into VBA code?

JKwan
09-09-2011, 06:23 AM
last question @JKwan: is there anyway to put that [or something like it] into VBA code?

I don't understand, what I gave you is VBA codes..... Unless you don't want the Checkboxes on the spreadsheet and use a form, is this what you are referring?