+ Reply to Thread
Results 1 to 8 of 8

Clicking on a button linked to VBA code fails to execute

  1. #1
    Forum Contributor
    Join Date
    12-03-2021
    Location
    Brussels
    MS-Off Ver
    Microsoft 365
    Posts
    186

    Clicking on a button linked to VBA code fails to execute

    Dear,

    Please check the file attached, and have a look at the worksheet "GENERAL".

    There is a button called "OFFRE" which is linked to :

    1) the below subroutine in the worksheet "GENERAL" to define the preconditions of the button's execution

    Please Login or Register  to view this content.
    2) the below module to show or hide certain tabs depending on the value defined in the above routine.

    Please Login or Register  to view this content.
    However, when I click on the button, there is a "400" error without any additional message or warning. I can't figure what is the issue.

    (If needed, password: 9583)

    Can someone help me please? Thanks
    Attached Files Attached Files
    Last edited by jeriss; 01-19-2023 at 09:52 AM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,968

    Re: Clicking on a button linked to VBA code fails to execute

    The worksheet is protected and your code tries to change a cell value on it without unprotecting it.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    12-03-2021
    Location
    Brussels
    MS-Off Ver
    Microsoft 365
    Posts
    186

    Re: Clicking on a button linked to VBA code fails to execute

    Indeed, but I have the same protection and the same type of code for showing/hiding the same tabs through the buttons "FACTURE" and "DEVIS" but such errors don't appear in that case. Why wouldn't the protection cause an issue in that case, why would it in this case? Thanks

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,968

    Re: Clicking on a button linked to VBA code fails to execute

    Those buttons both populate G1, which is unlocked, not E1 which is locked.

  5. #5
    Forum Contributor
    Join Date
    12-03-2021
    Location
    Brussels
    MS-Off Ver
    Microsoft 365
    Posts
    186

    Re: Clicking on a button linked to VBA code fails to execute

    I unlocked E1 but I still get the same error "400 error vba application"
    Attached Images Attached Images

  6. #6
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,941

    Re: Clicking on a button linked to VBA code fails to execute

    On your General sheet, E1 is a merged cell. Please try unmerging it.

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,968

    Re: Clicking on a button linked to VBA code fails to execute

    Your code then tries to select A6 on the OFFRE DE PRIX sheet, which is not active, so that will fail. You should activate it first (or use Application.Goto).

  8. #8
    Forum Contributor
    Join Date
    12-03-2021
    Location
    Brussels
    MS-Off Ver
    Microsoft 365
    Posts
    186

    Re: Clicking on a button linked to VBA code fails to execute

    Indeed, removing the lines of code "select" solved the issue.

    Please Login or Register  to view this content.
    Thanks all !

+ 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. run code once a time when clicking the run button
    By pmchris in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-20-2020, 11:18 PM
  2. Clicking a FORM CONTROL Button using VBA code.
    By ayush_9924 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-12-2015, 12:47 AM
  3. code to execute a keyboard shortcut or to execute a toolbar button
    By Gti182 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-09-2015, 12:16 PM
  4. How To execute a button (click event) with code?
    By jamiguel77 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2014, 11:22 AM
  5. Code to clear check box fails to execute
    By brharrii in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-18-2013, 03:51 PM
  6. How to find the VBA code of a button without clicking it??
    By techcrium in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-19-2012, 02:36 PM
  7. [SOLVED] How can I use VB code to execute macro when double-clicking cell?
    By JDay01 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-13-2006, 10:20 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