+ Reply to Thread
Results 1 to 3 of 3

VBA UserForm causing errors for SharePoint users

  1. #1
    Registered User
    Join Date
    08-26-2022
    Location
    Liverpool, England
    MS-Off Ver
    Office 365
    Posts
    10

    VBA UserForm causing errors for SharePoint users

    Greetings, I hope some of you can help me with this.
    I have created a UserForm via VBA code and ever since this was implemented into the spread sheet we have started receiving errors like "Your changes could not be saved" or "excel cannot save changes made by another user" any idea why this form might be causing that?
    I have several Macros running including AuditLog and everything works smoothly but when another user opens the file while someone is adding stock via the form everything goes **** up.

    Hope someone can help.

    Here is the code for activating the form in the spreadsheet:
    Private Sub CommandButton1_Click()
    add_frm.Show
    End Sub
    And here is the code of the UserForm itself:
    Private Sub CommandButton1_Click()
    Dim sht As Worksheet, sht1 As Worksheet, lastrow As Long
    ''''''''Validation''''''''

    If Me.TextBox1.Value = "" Then
    MsgBox "Please enter a correct location", vbCritical
    Exit Sub
    End If

    If VBA.IsNumeric(Me.TextBox2.Value) = False Then
    MsgBox "Please enter a correct GRN", vbCritical
    Exit Sub
    End If

    If Me.TextBox3.Value = "" Then
    MsgBox "Please enter a correct item code", vbCritical
    Exit Sub
    End If

    If Me.TextBox6.Value = "" Then
    MsgBox "Please enter transaction date", vbCritical
    Exit Sub
    End If

    If Me.TextBox6.Value = "" Then
    MsgBox "Please enter quantity", vbCritical
    Exit Sub
    End If

    If Me.OptionButton1.Value = False And Me.OptionButton2.Value = False And Me.OptionButton3.Value = False And Me.OptionButton4.Value = False Then
    MsgBox "Please select status", vbCritical
    Exit Sub
    End If

    ''''''''End of Validation''''''''
    Set sht = ThisWorkbook.Sheets("WH STOCK")

    lastrow = sht.Range("a" & Rows.Count).End(xlUp).Row + 1


    ''''sh.unprotect code - if ever I needed''''
    With sht

    .Range("A" & lastrow).Value = Me.TextBox1.Value
    .Range("B" & lastrow).Value = Me.TextBox2.Value
    .Range("C" & lastrow).Value = Me.TextBox3.Value
    .Range("D" & lastrow).Value = Me.TextBox4.Value
    .Range("G" & lastrow).Value = Me.TextBox5.Value
    .Range("H" & lastrow).Value = "Y"
    .Range("I" & lastrow).Value = Me.TextBox6.Value
    .Range("K" & lastrow).Value = Me.TextBox7.Value
    .Range("L" & lastrow).Value = Me.TextBox10.Value
    .Range("M" & lastrow).Value = Me.TextBox11.Value
    .Range("N" & lastrow).Value = Me.TextBox13.Value
    .Range("O" & lastrow).Value = Me.TextBox14.Value
    .Range("P" & lastrow).Value = Me.TextBox15.Value
    .Range("Q" & lastrow).Value = Me.TextBox16.Value
    .Range("R" & lastrow).Value = Me.TextBox17.Value
    .Range("G" & lastrow).NoteText Text:=add_frm.TextBox18.Value


    ''''sh.protect code - if ever I needed''''

    End With
    sht.Activate
    If Me.OptionButton1.Value = True Then sht.Range("J" & lastrow).Value = "APPROVED"
    If Me.OptionButton2.Value = True Then sht.Range("J" & lastrow).Value = "ON HOLD"
    If Me.OptionButton3.Value = True Then sht.Range("J" & lastrow).Value = "REJECT"
    If Me.OptionButton4.Value = True Then sht.Range("J" & lastrow).Value = "QUARANTINE"

    Exit Sub


    End Sub

    Private Sub CommandButton2_Click()
    Me.TextBox1.Value = ""
    Me.TextBox2.Value = ""
    Me.TextBox3.Value = ""
    Me.TextBox4.Value = ""
    Me.TextBox5.Value = ""
    Me.TextBox6.Value = ""
    Me.TextBox7.Value = ""
    Me.TextBox10.Value = ""
    Me.TextBox11.Value = ""
    Me.TextBox13.Value = ""
    Me.TextBox14.Value = ""
    Me.TextBox15.Value = ""
    Me.TextBox16.Value = ""
    Me.TextBox17.Value = ""
    Me.TextBox18.Value = ""

    Me.OptionButton1.Value = False
    Me.OptionButton2.Value = False
    Me.OptionButton3.Value = False
    Me.OptionButton4.Value = False

    End Sub

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,335

    Re: VBA UserForm causing errors for SharePoint users

    if you run 'debug' do you get any comment at the row below - the code is alien to me.
    Please Login or Register  to view this content.
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  3. #3
    Registered User
    Join Date
    08-26-2022
    Location
    Liverpool, England
    MS-Off Ver
    Office 365
    Posts
    10

    Re: VBA UserForm causing errors for SharePoint users

    No I don't but I have removed this right before you posted your reply and tested everything and it works. So killing the "add comment" section on the form did the trick. Thank you for your reply

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Forum causing errors - again
    By Logit in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-18-2017, 12:55 PM
  2. Forum causing errors - again
    By Logit in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-18-2017, 12:25 PM
  3. [SOLVED] Sorting causing errors with lookups
    By Khoori7 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-26-2013, 10:49 PM
  4. An additional IF causing errors in the whole formula
    By dyuk in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-28-2012, 03:21 AM
  5. multiple worksheet_changes causing errors
    By daschmidt in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-17-2012, 03:15 PM
  6. DB refresh causing errors
    By goofy78270 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-13-2007, 05:36 PM
  7. [SOLVED] sumproduct causing memory errors?
    By dave in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-03-2005, 06:06 AM

Tags for this Thread

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