+ Reply to Thread
Results 1 to 5 of 5

Macro works great in 2007 but not in older excel format

Hybrid View

Tom R. Macro works great in 2007 but... 04-17-2013, 05:54 PM
JosephP Re: Macro works great in 2007... 04-17-2013, 06:26 PM
Tom R. Re: Macro works great in 2007... 04-17-2013, 07:14 PM
JosephP Re: Macro works great in 2007... 04-18-2013, 03:25 AM
Tom R. Re: Macro works great in 2007... 04-18-2013, 05:52 AM
  1. #1
    Registered User
    Join Date
    04-08-2013
    Location
    Cape Cod
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    9

    Question Macro works great in 2007 but not in older excel format

    Macro works great in 2007 created from a expert in this forum. One associate I work with uses a older excel format 98 I believe and willl not upgrade??.

    The code below errors when promting the user here
     With Application.FileDialog(msoFileDialogOpen)
    I also would bet it would error elsewhere too. Is there anyone that could help out converting this code to the earlier version.

    Option Explicit
    Private Sub Workbook_Open() 
        Dim wb1 As Workbook, wb2 As Workbook
        Dim cell As Range, counter As Long
        
        ' Prompt user to select a file1
        With Application.FileDialog(msoFileDialogOpen)
            .InitialFileName = ThisWorkbook.Path              ' Default path
            .FilterIndex = 3
            .Title = "Please Select a File"
            .ButtonName = "Open"
            .AllowMultiSelect = False
            .Show
            If .SelectedItems.Count = 0 Then Exit Sub   ' User clicked cancel
            Set wb1 = Workbooks.Open(Filename:=.SelectedItems(1))
        End With
        
        ' Prompt user to select a file2
        With Application.FileDialog(msoFileDialogOpen)
            .InitialFileName = ThisWorkbook.Path              ' Default path
            .FilterIndex = 3
            .Title = "Please Select a File"
            .ButtonName = "Open"
            .AllowMultiSelect = False
            .Show
            If .SelectedItems.Count = 0 Then Exit Sub   ' User clicked cancel
            Set wb2 = Workbooks.Open(Filename:=.SelectedItems(1))
        End With
        
        For Each cell In wb1.Sheets(1).Range("E11:H25")
            If Not IsEmpty(cell) Then
                If cell.Value = wb2.Sheets(1).Range(cell.Address).Value Then
                    cell.Interior.Color = vbYellow
                    wb2.Sheets(1).Range(cell.Address).Interior.Color = vbYellow
                    counter = counter + 1
                End If
            End If
        Next cell
        
        MsgBox counter & " Duplicates Highlighted", vbInformation, "Comparison Complete"
       Me.Close True
    Debug.Print
    End Sub
    Thanks, Tom

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Macro works great in 2007 but not in older excel format

    does he use a mac or did you mean 97 rather than 98?
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    04-08-2013
    Location
    Cape Cod
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    9

    Re: Macro works great in 2007 but not in older excel format

    Hello, Thanks, for your reply... Joe Also, sorry for the time lag. I had to reboot. My co-worker has 97

    I tried to record the macro with his excel but this did not work. This was a attept to see if I could do it. But im green at it.

    Regards, Tom

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Macro works great in 2007 but not in older excel format

    the filedialog didn't exist in office 97 but I'm afraid I can't help beyond that because I don't have a copy of office 97!

  5. #5
    Registered User
    Join Date
    04-08-2013
    Location
    Cape Cod
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    9

    Re: Macro works great in 2007 but not in older excel format

    Thanks, Joe for your reply. I'm sure not many are using office 97 anymore. I'll still plug around this issue since there won't be any upgrade on his system. Stubburn is what stuburn does.

    Best Regards, Tom

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1