+ Reply to Thread
Results 1 to 8 of 8

How to prevent compilation of a field on condition based

  1. #1
    Registered User
    Join Date
    05-26-2017
    Location
    Rome
    MS-Off Ver
    OFFICE 2006
    Posts
    4

    Unhappy How to prevent compilation of a field on condition based

    Hi everybody,

    I try to write the following VBA code in order to prevent the compilation of the fields "Imponibile" and "IVA" when "TipoDocumentazione"= Ricevuta (see attached image). Immagine.png

    I have two types of problem:
    1) the fields "Imponibile" and "IVA" can still be compiled
    2) doing modification on other fields on excel file, the "non corresponding types - runtime error" appears

    Where I am wrong?

    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: How to prevent compilation of a field on condition based

    Try this. If your sheet is protected, uncomment the two green lines and change the password to suit.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: How to prevent compilation of a field on condition based

    Locking a cell has no effect unless and until a worksheet is Protected. The Lock property determines what happens to that cell when the sheet is protected. It does nothing until the sheet is protected.

    This approach might work for you.
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: How to prevent compilation of a field on condition based

    duplicate error

  5. #5
    Registered User
    Join Date
    05-26-2017
    Location
    Rome
    MS-Off Ver
    OFFICE 2006
    Posts
    4

    Re: How to prevent compilation of a field on condition based

    It seems it works only in some situations.. (it make not sense, I know..).. see attached imageImmagine.png

  6. #6
    Registered User
    Join Date
    05-26-2017
    Location
    Rome
    MS-Off Ver
    OFFICE 2006
    Posts
    4

    Re: How to prevent compilation of a field on condition based

    Same behaviour...

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: How to prevent compilation of a field on condition based

    I thought that if the cell in column G said "Ricevuta" you wanted the cells in uncompleted, i.e. empty.

  8. #8
    Registered User
    Join Date
    05-26-2017
    Location
    Rome
    MS-Off Ver
    OFFICE 2006
    Posts
    4

    Re: How to prevent compilation of a field on condition based

    Quote Originally Posted by mikerickson View Post
    I thought that if the cell in column G said "Ricevuta" you wanted the cells in uncompleted, i.e. empty.
    yes, I want that.

    It seems there is something wrong in the code because actually I can fill the "Imponibile" and "IVA" fields; I attach the code
    Please Login or Register  to view this content.
    and the table screenshot
    Immagine.png

+ 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. [SOLVED] Prevent user from closing file until condition is met
    By Gti182 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-18-2017, 02:28 AM
  2. Replies: 0
    Last Post: 06-26-2012, 09:06 PM
  3. Condition format prevent no is repeat
    By choy96 in forum Excel General
    Replies: 2
    Last Post: 12-25-2011, 12:19 PM
  4. Select worksheet based on condition & populate cell based on condition
    By beth1069 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2011, 01:27 PM
  5. Defining a Text field based on its condition
    By C.Hirsch in forum Excel General
    Replies: 3
    Last Post: 05-30-2006, 02:55 PM
  6. [SOLVED] Conditional Compilation Based On Excel Version
    By Josh Sale in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-13-2005, 05:05 PM
  7. prevent event procedure under condition
    By short_n_curly in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-27-2005, 04:05 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