Hi there
I have two excel sheets open.
With VBA code, I search+replace for all rows on the "mainsheet" to look for matching data on "data_sheet" and, if found, data is updated on the "mainsheet".
This works well but it is too slow.
I do the search+replace with next loops like this:
for x=1 to 10000 ' mainsheet rows
for z=1 to 1000 ' data_sheet rows
if mainsheet.range("A" & x)=data_sheet.range("A" & z) and mainsheet.range("B" & x)=data_sheet.range("B" & z) THEN
mainsheet.range("C" & x)=data_sheet.range("C" & z)
end if
next z
next x
It is a bit more complex than that but more or less that's the routine.
Like I said, it works, but because of the double loop, it takes a while, specially if the sheets have a lot of rows.
On the example above I put 2 cell match, however sometimes it has to match up to 5 cells.
The question is, is there a faster/better way to do this kind of global updates with VBA between two sheets ?
basically I need to do like an Query in Access (SQL), which is very fast, but with Excel.
Any ideas/comments will be appreciated.
thanks in advance
I have two excel sheets open.
With VBA code, I search+replace for all rows on the "mainsheet" to look for matching data on "data_sheet" and, if found, data is updated on the "mainsheet".
This works well but it is too slow.
I do the search+replace with next loops like this:
for x=1 to 10000 ' mainsheet rows
for z=1 to 1000 ' data_sheet rows
if mainsheet.range("A" & x)=data_sheet.range("A" & z) and mainsheet.range("B" & x)=data_sheet.range("B" & z) THEN
mainsheet.range("C" & x)=data_sheet.range("C" & z)
end if
next z
next x
It is a bit more complex than that but more or less that's the routine.
Like I said, it works, but because of the double loop, it takes a while, specially if the sheets have a lot of rows.
On the example above I put 2 cell match, however sometimes it has to match up to 5 cells.
The question is, is there a faster/better way to do this kind of global updates with VBA between two sheets ?
basically I need to do like an Query in Access (SQL), which is very fast, but with Excel.
Any ideas/comments will be appreciated.
thanks in advance