E
Ed
I regularly update a workbook that has manually inserted comments down
one column. To update, I get a new report from the database, then run
a macro that arranges and formats certain report columns into a
summary master workbook. So far, so good.
Than I have to copy across the comments. Sometimes new data is added
into or subtracted from the middle of the data range, so it's not as
simple as copying everything over and anything at the bottom is new.
As far as I can see, I would need to make a comparison string of 4 or
5 columns across a single row in the updated summary, then find this
in the previous summary and copy across the comment that is in the row
where the comparison matched. I could see a brute force matchup along
the lines of:
rwNew = count of rows in new
rwPrev = count of rows in previous
' x refers to range in new book
'y refers to range in previous book
For x = 1 To rwNew
For y = 1 To rwPrev
strNew = Values of Cells(x,4) through Cells(x,8)
strPrev = Values of Cells(y,4) through Cells(y,8)
If strPrev = strNew Then
Cell(x,10) = Cell(y,10)
Exit For
End If
Next y
Next x
Is there a better, faster, easier way to accomplish this?
Ed
one column. To update, I get a new report from the database, then run
a macro that arranges and formats certain report columns into a
summary master workbook. So far, so good.
Than I have to copy across the comments. Sometimes new data is added
into or subtracted from the middle of the data range, so it's not as
simple as copying everything over and anything at the bottom is new.
As far as I can see, I would need to make a comparison string of 4 or
5 columns across a single row in the updated summary, then find this
in the previous summary and copy across the comment that is in the row
where the comparison matched. I could see a brute force matchup along
the lines of:
rwNew = count of rows in new
rwPrev = count of rows in previous
' x refers to range in new book
'y refers to range in previous book
For x = 1 To rwNew
For y = 1 To rwPrev
strNew = Values of Cells(x,4) through Cells(x,8)
strPrev = Values of Cells(y,4) through Cells(y,8)
If strPrev = strNew Then
Cell(x,10) = Cell(y,10)
Exit For
End If
Next y
Next x
Is there a better, faster, easier way to accomplish this?
Ed