cancel
Showing results for 
Search instead for 
Did you mean: 

Copy and paste visible cells in excel

Murali_MohanKon
Level 4
Hi Team,

Please help for Copy and paste visible cells data in excel using code stage or any alternatives. thank you.

------------------------------
Murali Mohan Konanki
UTC
8096961984
------------------------------
16 REPLIES 16

Hi Murali
Thank you So much
Your Code works!

------------------------------
Aarthi Komandur Seshadri RPA Developer
------------------------------

Hi Murali.
Thank you again for your help. This code  works fine, just that  it adds one extra row at the end, could  you please tell me if there is a way to not have that extra row created
15891.png
You can see the from the above screenshot, next to TEST2 row, one additional row is added. 

Thanks

------------------------------
Aarthi Komandur Seshadri RPA Developer
------------------------------

I have a excel sheet with 7 spreadsheets,

I have to filter for specific criteria and I want to copy the filtered data from one sheet to another.

o for copying the visible cells I am trying to use your code, but I am getting  the following error.

Can you please help me with this.


Code:
Dim Worksheet As Object
Worksheet = GetWorkbook(handle, Nothing). ActiveSheet
newRange = Worksheet.AutoFilter.Range.SpecialCells(xlCellTypeVisible)

Error:
Internal : Could not execute code stage because exception thrown by code stage: Unable to get the SpecialCells property of the Range class

------------------------------
Gordon Bullard & Company

Hi @jacksonliam,

In order to apply filter for specific criteria, you can refer below video:

https://www.youtube.com/watch?v=GiQgvUhbFM0

Post applying filter, since you want to copy paste the data to other sheet, please follow below steps:


1) After applying filter, Use "Select" action of "MS Excel VBO"​ to select the data (e.g. A:D). This will select the whole column A to D (assuming the filter is applied on column A to D).
2) Use "Copy" action of MS Excel VBO to copy the selected data.
3) Use "Activate Worksheet" of MS Excel VBO to activate the destination worksheet.
4) Use "Go to Cell" action of MS Excel VBO and go to the cell where it needs to be pasted (e.g. A1)
5) Use "Paste" action of MS Excel VBO to paste the data. It will copy and paste the filtered set of data.

Hope it helps.



------------------------------
Ritansh Jatwani Senior Consultant
Consultant
EY
Gurgaon
*If you find this post helpful mark it as best answer
------------------------------

Hi 

you can use the above code which was mentioned by Murali. I watched the w video on YouTube by Ritansh jatwani. After auto-filtering I used the code shared by Murali and it's absolutely working fine.

For getting the range: you can use get number of rows action available in Ms Excel VBO and just use this inside the code. 

thanks Ritansh for making a video on Auto filter. Your code exactly  worked for me. 



------------------------------
Aarthi Komandur Seshadri RPA Developer
------------------------------

Hi @Janu,

Thanks for the feedback. Glad to know that the video helped you. :)​

------------------------------
Ritansh Jatwani Senior Consultant
Consultant
EY
Gurgaon
*If you find this post helpful mark it as best answer
------------------------------

Hi Jackson,

Can you share a snap of the excel sheet you are working on?

------------------------------
Murali Krishna
RPA Consultant
------------------------------