简体   繁体   中英

Excel macro to move data from one sheet to another based column name and cell content

I have a worksheet1 with a column labeled participant and columns labeled 1-20 (experiment ID numbers).

I have another worksheet2 with data of participants (column) and the experiments (column) they participated in.

What I need to do is place an "X", on worksheet1, in the corresponding cells from worksheet2.

Here are some images that show what I mean:

在此处输入图片说明

在此处输入图片说明

You should use a pivot table. It will get you exactly what you are looking for.

Row Label: Participant
Col Label: Experiment
Values: Count of Experiment

Then you would need to change all the "1"s to "X" with find/replace (either manually or with macro):

Range(pivottablecells).Replace("1", "X")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM