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
Bookmarks