PDA

View Full Version : VBA Code to copy value in a cell and paste in at the first row of the Table



ipmh97
08-20-2021, 06:45 AM
​Hi, I have to clean different excel sheets with separate tables within each sheet. I have written a vba code to extract rows between two values and paste them onto a new sheet. The issue I have now is that I want to consolidate the rows in the new sheet into a total instead of individual rows.

28860



From the above pic, I want the total quantity (which is 9) for the top table to replace the "1" in the first row. Thereafter, I want to delete all rows below the first row of the table till the start of the next company. After that, I want to repeat the process for Company B's table. How do I write the vba code for this? I was thinking of using find​​ to search for "Total" and use offset after that but I'm not sure if that's possible. I have uploaded the excel workbook. You need to run the Selectbetween macro first before reaching the above step. Thank you

arnelgp
08-20-2021, 06:52 AM
can you share the file (excel, image, etc) to a sharing site (dropbox, google drive, etc)
and paste the link. right now i am unable to open your attachment.

ipmh97
08-20-2021, 07:07 AM
Hi sorry about that. Here's the link
https://drive.google.com/drive/folders/1ILmF_b_4ESZ_ck_K6mArPsPJABrs7wwx?usp=sharing

arnelgp
08-20-2021, 08:28 AM
see if this is what you need.
https://www.dropbox.com/scl/fi/x3elpvlapowgodw1j9det/Book1.xlsm?dl=0&rlkey=ac8lxv5zcqqxo6uby07s57z80

ipmh97
08-20-2021, 07:51 PM
Yes it is. Thank you!