+ Reply to Thread
Results 1 to 1 of 1

Run-Time Error 1004 When Running Macro from Another Personal Workbook (xlsb)

Hybrid View

vcs1161 Run-Time Error 1004 When... 04-01-2013, 12:05 PM
  1. #1
    Registered User
    Join Date
    12-13-2012
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    40

    Question Run-Time Error 1004 When Running Macro from Another Personal Workbook (xlsb)

    I have this macro saved in a shared directory and the end user is receiving thie run-time error as seen in the attached document. Here is the macro that is saved in a .xlsb workbook that other users can access and use. I can run this fine from my stand alone system but not sure yet why another user is getting this message. Is it something to do with how you open an activate the .xlsb workbook that contains the macros?

    Sub AnotherTestSplit()
    Dim lastrow As Long
    Dim LastCol As Integer
    Dim i As Long
    Dim iStart As Long
    Dim iEnd As Long
    Dim ws As Worksheet
    Dim Master As String
    Dim FirstWSToSort As Integer
    Dim LastWSToSort As Integer
    Dim s As Integer
    Dim j As Integer
    Dim RngSel As String
    Dim ColLookup As String
    Dim rs As Range
    
    On Error Resume Next
    Application.DisplayAlerts = False
    
    Set rs = Application.InputBox(Prompt:="Click on Column Letter for Lookup", Title:="Range Select", Type:=8)
    On Error GoTo 0
    
            Application.DisplayAlerts = True
            If rs Is Nothing Then
            Exit Sub
            Else
           ColLookup = rs.Address
    End If
    
      ColLookup = Left(rs.Address(False, False), 1 + -1 * (rs.Column > 26))
    
    Application.ScreenUpdating = False
    With ActiveSheet
    Master = .Name
        Application.DisplayAlerts = False
        For Each ws In ThisWorkbook.Worksheets
            If ws.Name <> .Name Then ws.Delete
        Next ws
        Application.DisplayAlerts = True
        lastrow = .Cells(Rows.Count, ColLookup).End(xlUp).Row
        LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column
        .Range(.Cells(2, 1), Cells(lastrow, LastCol)).Sort Key1:=Range(ColLookup & 2), Order1:=xlAscending, _
            Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
        iStart = 2
        For i = 2 To lastrow
            If .Range(ColLookup & i).Value <> .Range(ColLookup & i + 1).Value Then
                iEnd = i
                Sheets.Add After:=Sheets(Sheets.Count)
                Set ws = ActiveSheet
                On Error Resume Next
                ws.Name = .Range(ColLookup & iStart).Value
                On Error GoTo 0
                ws.Range(Cells(1, 1), Cells(1, LastCol)).Value = .Range(.Cells(1, 1), .Cells(1, LastCol)).Value
                With ws.Rows(1)
                    .HorizontalAlignment = xlCenter
                    With .Font
                      '  .ColorIndex = 5
                        .Bold = True
                    End With
                End With
                .Range(.Cells(iStart, 1), .Cells(iEnd, LastCol)).Copy Destination:=ws.Range("A2")
                iStart = iEnd + 1
            End If
            
            For s = 1 To Sheets.Count - 1
           For j = s + 1 To Sheets.Count
               If StrComp(Sheets(s).Name, Sheets(j).Name) > 0 Then Sheets(j).Move After:=Sheets(Master)
             Next
        Next
          
            Next i
        
    End With
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    Sheets(Master).Activate
    End Sub
    
    Function WksExists(wksName As String) As Boolean
    On Error Resume Next
    WksExists = CBool(Len(Worksheets(wksName).Name) > 0)
    End Function
    Attached Files Attached Files

+ 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