cancel
Showing results for 
Search instead for 
Did you mean: 

delete a row in an excel file

SOLVED
KJ
Occasional Contributor

delete a row in an excel file

I am attempting to use this line of code from a very old post:

oWorkbook.ActiveSheet.Rows(2).Delete;

This doesn't seem to work.  The Test Complete type ahead only contains Cell, CelCount and Row Count.  I simply want to delete one row or a range of rows from an excel file. 

 

Any assistance is appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
AlexKaras
Community Hero

Re: delete a row in an excel file

Hi,

 

Is there a paste option

For example:

https://www.google.com/search?q=excel+vbscript+copy+paste+data

https://stackoverflow.com/questions/28816210/excel-vbscript-copy-and-paste-cell-values-to-end-of-ano...

 

And the whole Excel COM documentation.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

8 REPLIES 8
Marsha_R
Community Hero

Re: delete a row in an excel file

What is it that you are trying to do with the data that ends up with you deleting it?  Best practice is to not delete your test data.  Perhaps we can find you another way to run the test without doing that.

KJ
Occasional Contributor

Re: delete a row in an excel file

Actually the task is a little bit trickier then that.  I have three excel files.  I need to manipulate each one, for example

 

Excel1 - delete the first five rows and the last row of data, then copy all data in three columns and paste into Excel3.

 

Excel 2 - copy data from three columns and then paste into Excel3

This kind of task was doable in UFT, but now that I am using Test Complete, it's a lot different.

Any help is appreciated.

Marsha_R
Community Hero

Re: delete a row in an excel file

How do you get this data into Excel1 and Excel2 in the first place?

KJ
Occasional Contributor

Re: delete a row in an excel file

Data from Excel 1 and Excel 2 come from outside data sources.  Excel 3 contains formulas which will compute the information from Excel 1 and Excel 2.  The data itself is not actually important, I just need to delete specific rows from the spreadsheet.  

AlexKaras
Community Hero

Re: delete a row in an excel file

Hi,

 

This doesn't seem to work

If https://stackoverflow.com/questions/31878154/delete-rows-x-to-y-in-on-a-specific-excel-worksheet does not help, could you elaborate what does 'This doesn't seem to work' mean?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
KJ
Occasional Contributor

Re: delete a row in an excel file

Alex,

I found that I need to access the excel com directly to at least delete a row.  using this

wkbExported = appExcel.Workbooks.Open("\\\\network\\\\folder1\\\\folder2\\\\folder3\\\\datafile_20210113.csv");

wkbExported.ActiveSheet.Range("1:1").Delete();

or to delete columns using this:

wkbExported.ActiveSheet.Range("J:J").Delete();

Is there a paste option when copying from one file to another?  I need to paste a large amount of data from one spreadsheet to another.  Please advise.

AlexKaras
Community Hero

Re: delete a row in an excel file

Hi,

 

Is there a paste option

For example:

https://www.google.com/search?q=excel+vbscript+copy+paste+data

https://stackoverflow.com/questions/28816210/excel-vbscript-copy-and-paste-cell-values-to-end-of-ano...

 

And the whole Excel COM documentation.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

sonya_m
Community Manager

Re: delete a row in an excel file

Thanks to everyone for participating in this discussion!

 

@KJ Does the advice help?


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors