How can i delete empty rows in an excel using for each row
@Yoichi
Thank you but the excel file is not created in my process, i need to use write range before read range and after that i need to delete empty rows
Hi,
Do you mean want to delete empty rows in datatable? If so, FilterDataTable activity is better.
if not, can you elaborate with specific sample?
Regards,
You don’t directly delete them from Excel. You read the Excel sheet into a datatable (this is what Read Range does), then remove empty rows from the datatable then use Write Range to write the data back to an Excel file without the empty rows.
Why would you write it, then read it, then remove empty rows, then write it again? This makes no sense. Remove the empty rows before you write it.
@postwick
The file is not existing, i need to create it before
No you don’t. The Write Range creates it. Get rid of the empty rows in the datatable before you write it.
this is what i do nn ?
No. The screenshot you posted shows that you are writing to the file twice, then reading, then filtering, then writing again. Insert/Delete Rows isn’t the right thing to use, also.
You have your data in a datatable. Use Filter Data Table to remove the empty rows from it before writing to the Excel file.
No. The screenshot you posted shows that you are writing to the file twice, then reading, then filtering, then writing again. Insert/Delete Rows isn’t the right thing to use, also.
You have your data in a datatable. Use Filter Data Table to remove the empty rows from it before writing to the Excel file.
You are writing to the file (Write Range) multiple times.
The first write range is to add only a specific header
The second write range is the add the all information without header
The read range takes the information from write range 1+2
The last one takes the whole file after deleting the empty lines
When i don’t use filter i have the right number of information
So i don’t understand why i have 4 times the same information?
Hi @Soudios
You can alse keep this as a alternative if it meets your requirements.
You can try with Filter Datatable
Steps
- Read range Excel sheet store in the variable
- Use Filter Datatable “Remove all the empty rows”
Regards
Sudharsan
This is exactly what i did but i have 4 times the same information in the last excel file
You mentioned For Each Row. Is the Excel Application Scope inside a loop?
Yes it is in a for each row, i can’t do that if its is ?