+ Reply to Thread
Results 1 to 2 of 2

VBA to check condition on save and do something if a condition isn't met

Hybrid View

  1. #1
    Registered User
    Join Date
    06-28-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    54

    VBA to check condition on save and do something if a condition isn't met

    Hi

    I am working on some code to make sure that certain columns are hidden and password protected when a user saves a file and have got this far but got stuck - can anyone help me with the part I'm missing please?

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Sheets("Headcount").Select

    if.Columns("C").Hidden.. - this is the line I can't get to work - I want it to determine if Column C is already hidden then just save but if not then the column should be hidden and the sheet should be locked with the password in the section below?

    Columns("C:E").Select
    Selection.EntireColumn.Hidden = True
    Range("A1").Select


    ActiveSheet.Protect Password:="password"
    End Sub

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: VBA to check condition on save and do something if a condition isn't met

    Have you tried

    If Columns("C").Hidden = True Then
    Alf

+ 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: 7
    Last Post: 06-01-2015, 06:05 PM
  2. condition check
    By AMITKUMARVERMA in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-01-2014, 02:03 AM
  3. [SOLVED] condition check formula Help
    By cdllt in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 02-26-2013, 01:23 AM
  4. Need Help to Open File from assigned Folder and Check one condition , Delete and Save.
    By Naveed Raza in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-13-2013, 02:23 PM
  5. Check 2 IF Condition
    By zit1343 in forum Excel General
    Replies: 3
    Last Post: 04-20-2012, 12:46 PM
  6. multi condition format? lookup and date condition valid for.
    By D_Rennie in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-13-2009, 11:37 AM
  7. Check delete condition.
    By pichai in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-29-2007, 01:36 AM

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