+ Reply to Thread
Results 1 to 4 of 4

BeforeSave method is not working PLEASE HELP

  1. #1
    Registered User
    Join Date
    10-22-2015
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    1

    BeforeSave method is not working PLEASE HELP

    Option Explicit

    Private Sub workbook_BeforeSave1(ByVal SaveAsUI As Boolean, Cancel)
    Dim i As Integer, MyWb As Object
    i = 1
    Set MyWb = ThisWorkbook.Sheets("WorkbookBeforeSave").Cells

    Do While MyWb(2, i).Value <> ""
    i = i + 1
    Loop

    If i = 5 Then
    Exit Sub
    End If

    MsgBox ("Please enter all the mandatory fields"), vbCritical
    Cancel = True

    End Sub

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: BeforeSave method is not working PLEASE HELP

    There is nothing like
    Please Login or Register  to view this content.
    in standard excel events
    change to
    Please Login or Register  to view this content.
    and please use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Edit post, highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    11-04-2013
    Location
    Chesham
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: BeforeSave method is not working PLEASE HELP

    Please Login or Register  to view this content.

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: BeforeSave method is not working PLEASE HELP

    1) is this code in standard module, worksheet module or in (it shall be here) in ThisWorkbook module?
    2) are events enabled? check it by writing in immediate window
    Please Login or Register  to view this content.
    and pressing Enter
    3) does worksheet WorkbookBeforeSave exists?
    4) how do you know it is not working? for instance: No msgbox pops-up while A2:F2 are filled and G2 is empty in WorkbookBeforeSave sheet?

+ 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. BeforeSave Macro Not Working
    By DMumme in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-14-2014, 01:00 PM
  2. BeforeSave not working properly
    By kingdt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-09-2007, 10:43 AM
  3. Sheet activate method in beforesave event
    By bdg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-31-2006, 09:50 PM
  4. [SOLVED] Sheet Activate method in beforesave event
    By bdg in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-31-2006, 12:10 PM
  5. Save method and BeforeSave event
    By mikelee101@hotmail.com in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-15-2005, 12:05 AM
  6. Replies: 9
    Last Post: 07-05-2005, 08:05 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