Hello!
I've created a code in Excel that verifies each cell in a specific range and acts in case the cell value is equal to some specific strings. The problem is that the code is taking too long to be executed, which is not very good to the user who is using this code on a daily basis.
Basically I have a table with N rows (dinamic) and X columns (specified by user what is the window he would like to see), where N are strings and X are dates. The current code is uses a while inside a while, which firstly goes on all the row and then goes to the row below. It does this until there is no names on the column (N+1). Code can be found below(simplified:
[code]
while ActiveCell.Offset(4, -ActiveCell.Column + 2).Value <> 0
While ActiveCell.Offset(6 - ActiveCell.Row, 0).Value <> "false"
If ActiveCell.Value <> "" Then
Call FuncionToTransferData
End If
ActiveCell.Offset(0, 1).Select
Wend
count2 = count2 + 1
Range(inicio).Offset(count2, 0).Select
Wend
[/code]
Is there any way I can optimize this? I was thinking about using the "For each cell in a range" function. Do you think this might improve the execution time? Good to appoint that I need it to go through the range line by line, this means it cannot go through each column and then go to another one...
Thank you in advance and have a great day!