Results 1 to 3 of 3

Editing an existing macro for a spreadsheet

Threaded View

  1. #1
    Registered User
    Join Date
    07-10-2014
    Location
    Hertfordshire, England
    MS-Off Ver
    2003
    Posts
    2

    Question Editing an existing macro for a spreadsheet

    Hi,

    I know almost nothing about VBA, so am having great difficulties with this! I have an existing spreadsheet that has been set up so that you have to fill in data in 3 specific columns before you save the spreadsheet. I want to add a fourth mandatory field. The Visual Basic code I have in the current spreadsheet is as follows:-

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
       If Application.CountA(Columns(10)) <> Application.CountA(Columns(20)) Or Application.CountA(Columns(20)) <> Application.CountA(Columns(26)) Then
           Cancel = True
           MsgBox "Please check New Trading Name, Main Usage and Officer's Intials are completed." & vbNewLine & vbNewLine & "This file cannot been saved unless they are."
       End If
    End Sub
    I thought I could edit it by adding an extra "Or" command like so:-

    Application.CountA(Columns(10)) <> Application.CountA(Columns(20)) Or Application.CountA(Columns(20)) <> Application.CountA(Columns(26)) Or Application.CountA(Columns(26)) <> Application.CountA(Columns(27)) Then
    However, doing that causes the spreadsheet to refuse to save at all, even if there is data in Column 27. I have entered data for the entire column but it still refuses to believe there's data there. What am I doing wrong? Any help gratefully received. I am using Excel 2003.

    Cheers!

    Lesley
    Last edited by Richard Buttrey; 07-10-2014 at 05:43 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How can i delete the non matching rows after compairing the 2 workbooks through Macro
    By Manish_Gupta in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-03-2013, 04:29 PM
  2. Editing Cell Formatting in an Existing (Damaged?) Macro
    By enturbulator in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-24-2012, 02:08 PM
  3. Editing existing macro help
    By ad9051 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-11-2011, 07:07 PM
  4. editing existing macro to add new column
    By dnmahendra in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-07-2010, 05:00 AM
  5. Editing existing Macro
    By jsheppard in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-11-2010, 12:11 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