+ Reply to Thread
Results 1 to 7 of 7

VBA Code with Listbox quit working after file was saved and reopened.

Hybrid View

  1. #1
    Registered User
    Join Date
    09-26-2019
    Location
    usa
    MS-Off Ver
    10
    Posts
    19

    VBA Code with Listbox quit working after file was saved and reopened.

    I had a vba code running perfectly fine but after i saved the file and reopened the macro stopped working.

    this code below
    Private Sub CommandButton8_Click()
     Dim sFind As String, rFound As Range
     
     Select Case Me.ProductOrderTable.Value
     Case Is <> vbNullString
     sFind = Me.ProductOrderTable.Value
     
     With Sheets("ProductTable")
     Set rFound = .Cells.Find(what:=sFind, After:=.Cells(1, 1))
     
     If Not rFound Is Nothing Then
    rFound.Range(Cells(2), Cells(4)).Select
        Selection.ClearContents
        
    Range("B" & ActiveCell.Row).Select
    Range("D" & ActiveCell.Row + 1, Cells(Range("B1000000").End(xlUp).Row, 2)).Select
    Selection.Copy
      Selection.Offset(-1, 0).Select
        ActiveSheet.Paste
    
    
        Range(Selection, Selection.End(xlDown)).Select
        Selection.End(xlDown).Select
        Range("D" & ActiveCell.Row + 1, Cells(Range("B1000000").End(xlUp).Row, 2)).Select
        Selection.ClearContents
                
        
     End If
     End With
     Case Else: Exit Sub
     End Select
    End Sub
    Can't figure out for the life of me why..
    I went back to previous saved files ( i save after every new change) when I had working codes, and the VBA for that same macro function don't work on there as well. Any assistance would be appreciated.

    Thanks in advance.

    Note: All my other macros work, just this particular VBA code with this listbox and command button.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA Code with Listbox quit working after file was saved and reopened.

    Please upload the workbook so that we may check

    On which line does the macro fail?
    Have you changed anything else, new PC, operating system., Excel version..Sheet name "Product Table"..?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    09-26-2019
    Location
    usa
    MS-Off Ver
    10
    Posts
    19

    Re: VBA Code with Listbox quit working after file was saved and reopened.

    Attached the file.

    VBA is in MasterForm (userform)

    Nothing changed. Just wrote made the code today, and was working fine all the way up until i saved and reopened.
    Last edited by nate.oyen; 02-07-2020 at 08:50 AM.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA Code with Listbox quit working after file was saved and reopened.

    Hi,

    Where does your code error?

    I get the error at the
    Set objFolder = objFSO.GetFolder(Range("PRF_Directory").Value)
    since the path is invalid

    I should also check B2 B4 & B5 on the Directory sheet. There may be some conflict between the Application user name and the Environ user name.

  5. #5
    Registered User
    Join Date
    09-26-2019
    Location
    usa
    MS-Off Ver
    10
    Posts
    19

    Re: VBA Code with Listbox quit working after file was saved and reopened.

    Yes you would get the error on that since that directory does not exist on your system.
    All the codes work on mine since it was made for my directories, which is over sharepoint.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA Code with Listbox quit working after file was saved and reopened.

    So have you recently moved to Sharepoint?

    On which line does your error occur? You've not mentioned that yet

  7. #7
    Registered User
    Join Date
    09-26-2019
    Location
    usa
    MS-Off Ver
    10
    Posts
    19

    Re: VBA Code with Listbox quit working after file was saved and reopened.

    everything works except the macro in my userform (masterform)
    Private Sub CommandButton8_Click()

    that's it.

    It doesn't run when it should do what it did when I initially made it.

    It should clear the selected item in the listbox and copy the rows below and paste them up and delete the last row.

+ 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. Replies: 0
    Last Post: 06-15-2016, 06:24 PM
  2. Replies: 2
    Last Post: 10-26-2015, 10:31 AM
  3. [SOLVED] Code quit working - will not format key text
    By Strepho63 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-21-2015, 01:45 PM
  4. Listbox items clear after worksheet is closed then reopened
    By skins0gr in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 05-24-2013, 12:02 PM
  5. Replies: 2
    Last Post: 02-20-2013, 08:27 AM
  6. VBA code quit working
    By Brad_G in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-29-2011, 10:45 AM
  7. VBA code does not work when file is reopened
    By rwhite713 in forum Excel General
    Replies: 2
    Last Post: 07-22-2010, 03:35 PM

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