Macro to copy-paste in a clever way

FarukibnFaruk

New Member
Joined
Aug 5, 2011
Messages
1
Salud,

I need some help to automatize a project.
I need some code to do something like that: In cell A2 and B2 I have data validation and in A5 an buton (STR). When I click buton STR I need a macro to make a folder with the name from cell A2 (here can be number or text) and copy with formating all between column D and AP from sheet1 in this file Project.xlsx and creat a file with name from B2 (here can be number or text), in folder new created.

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB"><colgroup><col width="25px" style="background-color: #DAE7F5" /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th><th>G</th><th>H</th><th>I</th><th>J</th><th>K</th><th>L</th><th>M</th><th>N</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style=";">Wind</td><td style=";">TTN</td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">9</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">10</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">11</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">12</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">13</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">14</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">15</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">16</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">17</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">18</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">19</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">20</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">21</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">22</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">23</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">24</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">25</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;background-color: #D9D9D9;;"></td><td style="text-align: right;;"></td></tr></tbody></table><p style="width:3,6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #BBB;border-top:none;text-align: center;background-color: #DAE7F5;color: #161120">Sheet1</p><br /><br />

In my example when I click on buton STR a macro must create a folder with name "Wind" and in this folder create a file named TEST with sheet named "TTN" and copy with formated all cells between column D and AP, and if I change "TTN" with say "SSD" and push buton STR because I don't change cell A2 "WIND" make another sheet named "SSD" in same folder and copy with formated all cells between column D and AP. I need to copy all cells between column D and AP becouse that cells is changed if I change cell A2 and/or B2. Uffff hope you understand.

I apreciate any help. Thank for patience.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

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