I need a bit more information on how you get the data to the sales page. I think some of your issues can be uncomplicated if the data (at least rows 1 through 31) were in an Excel table. Then you could run a "pointer" down the column. A table knows how big it is, so the pointer will know where to start and stop.
I'm still not all that clear what you want to copy from the Sale page to the Historico page. In some cases it looks like it is copying blank cells.
Also on the sales page, the formulas in column G could be simplified by doing a lookup. What you have seems to work fine. If I have to nest more than two if statements, I go for a lookup. However, that's my personal preference - either way works.
In the attached, I made a table on the Sale page. I had to hide the header since you have a dropdown value on row 17. Excel tables must have fixed headers. The real headers are on row 18 which is hidden. I also changed the dropdown for the units of measure from the hard coded that you had to read it from a lookup table. If you are using a list validation against a column in a table you can use the following syntax:
=INDIRECT("TableName[TableColumn]")
The validation will grow and shrink with the data in the table.
I also took the if statement out of column G and replaced it with: =IF(B19="","",VLOOKUP($G$17,Table_Units,2,FALSE)*[@Volume]) This looks up the value to multiply. It also means you do not have to recode anything should a new unit of measure come along. Just add the new unit to the table on the Lookups page.
With this setup I was able to run a pointer, cl, down the first column on Table_Sales. cl is a range. When used with For Each, it starts with the first cell in the range and moves on to the next cell in the range until it reaches the end. That's why I call it a pointer since it points to each cell in order.
This is where I am confused. it looks like you are copying static data, basically replicating the same row after row. I took a best guess as to what you wanted.
About the only thing to explain about the code is the use of offset. cl.Offset(0,5).Value means go zero rows down and 5 columns over from the cell where cl is pointing and get its value.
Bookmarks