Most valuable professional
  • Hot Topics

Excel Comparing two excel sheets, run time error '1004'

Hi guys this is my first post in this forum and I am new to macros, so please any feed back would help a lot I have a couple questions trying to program this, but let me ask them one at a time now. First, I am trying to do a file comparison macros on excel and highlight differences, however ran into a little error while doing this. In the code i have stated which line it is having the problem, I have read online articles and many people say that it is not good practice to use the '.select' so i am suspecting if that is why my error is occurring? Code: Option Explicit Sub Compare() Dim wb1 As Workbook, wb2 As Workbook Dim ws1 As Worksheet, ws2 As Worksheet Dim diffB As Boolean Dim r As Long, c As Integer, m As Integer Dim lr1 As Long, lr2 As Long, lc1 As Inte Dim maxR As Long, maxC As Integer, cf1 As Dim rptWB As Workbook, DiffCount As Long Application.ScreenUpdating = False Application.StatusBar = "Creating the rep Application.DisplayAlerts = True Set wb1 = Workbooks.Open("C:\A319") Set ws1 = wb1.Worksheets("BuildSheet") With ws1.UsedRange lr1 = .Rows.Count lc1 = .Columns.Count End With

This question generated 24 answers. To proceed to the answers, click here.

This thread is current as of May 8, 2014.

For more resources for Microsoft Excel:

This article includes the following tags:

  • Excel
  • Microsoft Excel