David Hawley (Compare-copy, From: Andonny


Posted by Joe Was on May 03, 2001 7:38 AM

Your help to Andonny looks like it could be of help to me as well, but I am having a problem adding a couple of twists to your code.

I would like your code to run from a Button and to take data from one (single project) workbook sheet and put it in a different workbook (data from all projects).

I am not as skilled as you are and am having trouble with the workbook reference and the "Range" works with a "Ctrl+ Macro" but fails in the Button code?

Any ideas?

Dim rCell As Range
Dim LookRange As Range
Application.ScreenUpdating = False

ActiveWorkbook.ChangeLink "H:\users\rw155jw\excel\Appraisal_Fees_Ver2_test.xls", "H:\users\rw155jw\excel\Appraisal_Fees_Search_File_test2.xls", xlLinkTypeExcelLinks

Set LookRange = Range("A6", Range("AB65536").End(xlUp))
For Each rCell In LookRange

If WorksheetFunction.CountIf _
(Sheets("Sheet3").Columns(1), rCell.Text) = 0 Then
rCell.Range("A6:AB6").Copy _
Destination:=Sheets("Sheet1").Range("A65536").End(xlUp).Offset(1, 0)

End If
Next rCell

Application.CutCopyMode = False
Application.ScreenUpdating = True

Posted by Dave Hawley on May 03, 2001 7:52 AM

Joe, if your button is from the "Control Toolbox", set its "TakeFocusOnClick" Property to False. Or use: Range("A1").select as the very first line.

Or consider using a button from the "Forms" Toolbar.

Dave


OzGrid Business Applications



Posted by Joe Was on May 03, 2001 8:04 AM

Thank's Dave, but I don't know how to reference the second workbook?

Dave,
I thought using the "ChangeLink" would set the object (wishful thinking). What is the syntax to copy to a different workbook?