Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile error when open by different User

Status
Not open for further replies.

aburamewolf

Technical User
Oct 12, 2011
18
US
Good Afternoon,

I really need some help, I'm new to VBA and I've been working on this subtract/replace information userform, it is dependent of auto filters

it's working fine in my computer and even in a different computer in the network when opened with my username however when a different user opens it, a Compile error comes up, yesterday I read how to fix this through References and I was able to do so yesterday as there was a "MISSING" component, however there is none coming up today.

Here's my code and I have a huge mental block at this point.

Code:
 Private Sub work1_Click()
 Dim timestamp As String
 Dim xrow As Variant
 Dim c1 As Long, cnotes As Long, cnt As Long, cx As Long, xr As Long, wr As Long
 Dim s1 As Range

 Sheets("Outbound").Select

 timestamp = Format(Now, "mmm ddd dd yyyy hh:mm:ss AM/PM")
 xrow = Range("L2").Row
 
 'Verifying If Fields Are Empty
 If oan.Text = "" And odispo.Text = "" And ostatus.Text = "" And ocontact.Text = "" And oterr.Text = "" And oaccname.Text = "" And oamount.Text = "" And onotes.Text = "" Then
    
    'Check If Filter Is Set
    If obucket.Text = "" Then
      MsgBox "Please Select a Bucket to work on", vbOKOnly, "ALERT"
    Exit Sub
    Else
      
      'Selecting Next Available Cell
      Do
      ActiveCell.Offset(1, 0).Select
      xr = ActiveCell.Row
      Loop Until ActiveCell.EntireRow.Hidden = False Or xr >= 1500
      xrow = ActiveCell.Row
      If xrow >= 1500 Then
       xrow = 2
      End If
    End If
         
         'Extract Information From Selected Row
         oan.Text = Cells(xrow, 5)
         odispo.Text = Cells(xrow, 9)
         ostatus.Text = Cells(xrow, 10)
         ocontact.Text = Cells(xrow, 11)
         oterr.Text = Cells(xrow, 2)
         oaccname.Text = Cells(xrow, 4)
         If obucket.Text = "0-30" Then
            oamount.Text = Cells(xrow, 6)
         ElseIf obucket.Text = "31-90" Then
            oamount.Text = Cells(xrow, 7)
         ElseIf obucket.Text = "91+" Then
            oamount.Text = Cells(xrow, 8)
         End If
         onotes.Text = Cells(xrow, 12)
        ofud.Text = Cells(xrow, 13)
        
 'Calculating If Fields Are Not Empty
 ElseIf oan.Text <> "" Then
         If odispo.Text = "" Then
           MsgBox "Please Choose A Dispostion", vbOKOnly, "ALERT"
           Exit Sub
         ElseIf ostatus.Text = "" Then
           MsgBox "Please Choose A Status", vbOKOnly, "ALERT"
           Exit Sub
         ElseIf ocontact.Text = "" Then
           MsgBox "Please Add Contact Information", vbOKOnly, "ALERT"
           Exit Sub
         ElseIf oterr.Text = "" Then
           MsgBox "Please Choose A Territory", vbOKOnly, "ALERT"
           Exit Sub
         ElseIf oaccname.Text = "" Then
           MsgBox "Please Add Store Number Or Account Name", vbOKOnly, "ALERT"
           Exit Sub
         ElseIf oamount.Text = "" Then
           MsgBox "Please Add Amount Being Collected", vbOKOnly, "ALERT"
           Exit Sub
         End If
           
          'Calculating Onotes.text's Variables
         If onotes.Text = "" Then
          MsgBox "Please Introduce A Note In Order To Save The Update", vbOKOnly, "ALERT"
          Exit Sub
         ElseIf onotes.Text <> "" Then
          cnt = Len(timestamp)
          c1 = Len(Cells(xrow, 12))
          cnotes = c1 + (Len(vbNewLine) * 2) + cnt
          cx = Len(onotes.Text)
           If cx = c1 Or cx = cnotes Or cx = cnt Or cx = 0 Then
              MsgBox "Please Introduce A Note In Order To Save The Update", vbOKOnly, "Alert"
            Exit Sub
           Else
            
            'Export Data To Selected Row
           
            'Production Date
            Cells(xrow, 3).Select
            ActiveCell = Format(Now, "mmm ddd dd yyyy hh:mm:ss AM/PM")

            'Disposition
            Cells(xrow, 9).Select
            ActiveCell = odispo.Text

            'Status
            Cells(xrow, 10).Select
            ActiveCell = ostatus.Text

            'Contact Information
            Cells(xrow, 11).Select
            ActiveCell = ocontact.Text
                    
            'Follow update
            Cells(xrow, 13).Select
            ActiveCell = ofud.Text
                    
            'Notes
            Cells(xrow, 12).Select
            ActiveCell = onotes.Text
                    
            'Amount
             If obucket.Text = "0-30" Then
             Cells(xrow, 6).Select
             ActiveCell = oamount.Text
             ElseIf obucket.Text = "0-30" Then
             Cells(xrow, 7).Select
             ActiveCell = oamount.Text
             ElseIf obucket.Text = "0-30" Then
             Cells(xrow, 8).Select
             ActiveCell = oamount.Text
             End If
            End If
         End If
        
         'Clear All Fields
         oan.Text = ""
         odispo.Text = ""
         ostatus.Text = ""
         ocontact.Text = ""
         oterr.Text = ""
         oaccname.Text = ""
         oamount.Text = ""
         onotes.Text = ""
         ofud.Text = ""
           
         'Refilter
         If obucket.Text = "0-30" Then
         Rows("2:1500").EntireRow.AutoFit
         '0-30 bucket hide blanks
         Range("A1:M1500").Select
         Selection.AutoFilter
         Selection.AutoFilter Field:=6, Criteria1:="<>"
         '0-30 bucket Sort
         Range("A1:M1500").Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:=Range( _
         "F2"), Order2:=xlDescending, Header:=xlGuess, OrderCustom:=1, MatchCase _
         :=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
         DataOption2:=xlSortNormal
         'selecting active cell
         Range("F1").Select
    
         ElseIf obucket.Text = "31-90" Then
         Rows("2:1500").EntireRow.AutoFit
         '31-90 bucke0t hide blanks
         Range("A1:M1500").Select
         Selection.AutoFilter
         Selection.AutoFilter Field:=7, Criteria1:="<>"
         '31-90 bucket Sort
         Range("A1:M1500").Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:=Range( _
         "G2"), Order2:=xlDescending, Header:=xlGuess, OrderCustom:=1, MatchCase _
         :=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
         DataOption2:=xlSortNormal
         'selecting active cell
         Range("G1").Select
         
         ElseIf obucket.Text = "91+" Then
         Rows("2:1500").EntireRow.AutoFit
         '91+ bucket hide blanks
         Range("A1:M1500").Select
         Selection.AutoFilter
         Selection.AutoFilter Field:=8, Criteria1:="<>"
         '91+ bucket Sort
         Range("A1:M1500").Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:=Range( _
         "G2"), Order2:=xlDescending, Header:=xlGuess, OrderCustom:=1, MatchCase _
         :=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
         DataOption2:=xlSortNormal
         'selecting active cell
         Range("H1").Select
    
         ElseIf obucket = "ALL" Then
         'Clearing filter by Amount
         Selection.AutoFilter Field:=6
         Selection.AutoFilter Field:=7
         Selection.AutoFilter Field:=8
         'Filter by Date Only
         Range("A1:M1500").Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase _
         :=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
         DataOption2:=xlSortNormal
         End If

 End If
End Sub

Any suggestion will be highly appreciated as I'm really trying to learn VBA right now.
 



Your other user needs to reload MS Office (Excel) as it seems a library may be missing.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks Skip,

I think figured out the issue although this only brought a lot more issues my way,

I unknowingly wrote a code in 2003 vba for an excel 2000 user so I was able to adapt the code on most parts but I'm having issue with the following piece of code that's in another userform that is also part of the project:

Code:
xrow = Cells.find(what:="*", lookat:=xlWhole, searchorder:=xlByRows, searchdirection:=xlPrevious).Row + 1

Any suggestions or should I just start over from scratch 'cause this is as far as I've gotten adapting the code I'm pretty sure more stuff will come up
 



how is xrow declared?


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 


No!
Code:
dim xrow as LONG
xrow = Cells.find(what:="*", lookat:=xlWhole, searchorder:=xlByRows, searchdirection:=xlPrevious).[highlight][b]Row + 1[/b][/highlight]
You are assigning a ROW NUMBER, so it should be declared as LONG.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top