View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
fullers fullers is offline
external usenet poster
 
Posts: 30
Default Improve macro help

I have the following code that works fine and does what I need it to do. What
I am wondering is if there is a way to improve the code inside the if
statement so that the 2 workbooks do not need to be alternately selected.
Thus I hope speed up the macro.

The bit inside takes a range of 120 cells in one row from "FromWorkbook"
then selects "ToWorkbook" and the first cell where the range is to be pasted
and then pastes the data.

If Workbooks(ToWorkbook).Sheets("LTDIS pay").Cells(j, 1).Value =
Workbooks(FromWorkbook).Sheets(1).Cells(i, 3).Value, 2) Then

Workbooks(FromWorkbook).Sheets(1).Activate
Range(Cells(i, 7), Cells(i, 127)).Copy
Workbooks(ToWorkbook).Sheets("LTDIS pay").Activate
Cells(j, 2).Select
ActiveSheet.Paste

End If

Many thanks in advance.