+ Reply to Thread
Results 1 to 14 of 14

Only allowing to fill a cell by the command button

  1. #1
    Registered User
    Join Date
    01-18-2024
    Location
    Brazil
    MS-Off Ver
    2013
    Posts
    19

    Only allowing to fill a cell by the command button

    Objective question this time.

    There is a way to lock an entire column, for instance, that only allows the user to fill the cells from that column clicking on a sheet command button (fetching data from some place), not allowing the person to type or edit directly ?
    I tried by the worsksheet change event, but it fires regardless of I fill the cells by the command button or typing values directly


    Sorry my bad english
    Last edited by MotroJena; 03-27-2024 at 09:57 AM.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Only allowing to fill a cell by the command button

    Hi, what I would suggest is that all actions directly to the worksheet be cancelled, but that you place a button somewhere on the worksheet that only unlocks the selected cell when you press that button, if there are special conditions or restrictions fpr that cell I would even go a little further and use a small userform for only one cell entry.
    You know there is an international section wher you can post your question in your own language.
    D'esta maneira podes receber respostas na tua lingua.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    01-18-2024
    Location
    Brazil
    MS-Off Ver
    2013
    Posts
    19

    Re: Only allowing to fill a cell by the command button

    Hi, thanks!

    The adjacents columns (H in this case) it will be used for calculations in real time (Worksheet change event). The user would type some numbers.
    I uploaded a sample. Consider the sheet 4 as the relevant sheet
    Attached Files Attached Files

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Only allowing to fill a cell by the command button

    I'm missing a library, what's that supposed to be?
    Attached Images Attached Images

  5. #5
    Registered User
    Join Date
    01-18-2024
    Location
    Brazil
    MS-Off Ver
    2013
    Posts
    19

    Re: Only allowing to fill a cell by the command button

    Selenium is a library required for web scraping, which I heavily used in this workbook.
    Sorry I will upload a new file only with the required sheet for the purpose soon

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Only allowing to fill a cell by the command button

    If you do not intend to share this file that's okay but keep in mind that addding non-commonly used libraries in workbooks you want to share with others will only give problems and errors

  7. #7
    Registered User
    Join Date
    01-18-2024
    Location
    Brazil
    MS-Off Ver
    2013
    Posts
    19

    Re: Only allowing to fill a cell by the command button

    No problem. Are you able to open the file even without the library?
    If so, that's ok

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Only allowing to fill a cell by the command button

    Yes, but it keeps blocking because of the missing library, I'll see if I can remove everything that references to that

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Only allowing to fill a cell by the command button

    No, it's too built in in you modules.
    Sorry, no go on my side

  10. #10
    Registered User
    Join Date
    01-18-2024
    Location
    Brazil
    MS-Off Ver
    2013
    Posts
    19

    Re: Only allowing to fill a cell by the command button

    Removed the modules
    Hope it works
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Only allowing to fill a cell by the command button

    I tried by the worsksheet change event, but it fires regardless of I fill the cells by the command button
    You could try:
    Declare a public variable blnButton as Boolean

    The in the click event of the Button
    Please Login or Register  to view this content.
    In the ChangeEvent of the sheet
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    01-18-2024
    Location
    Brazil
    MS-Off Ver
    2013
    Posts
    19

    Re: Only allowing to fill a cell by the command button

    Man, it worked!



    My idea was to create a static variable to count the number of times the click button wa pressed. But it woyld be a potential mess

    Thanks a lot!

  13. #13
    Registered User
    Join Date
    01-18-2024
    Location
    Brazil
    MS-Off Ver
    2013
    Posts
    19

    Re: Only allowing to fill a cell by the command button

    Quote Originally Posted by ByteMarks View Post
    You could try:
    Declare a public variable blnButton as Boolean

    The in the click event of the Button
    Please Login or Register  to view this content.
    In the ChangeEvent of the sheet
    Please Login or Register  to view this content.
    Man, it worked!



    My idea was to create a static variable to count the number of times the click button was pressed. But it would be a potential mess

    Thanks a lot!
    Last edited by MotroJena; 03-28-2024 at 08:55 AM.

  14. #14
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    1,980

    Re: Only allowing to fill a cell by the command button

    You're welcome.

+ 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] Copying ActiveX Command Button from master sheet to subsheets. command button code missing
    By popper08 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-13-2020, 10:15 AM
  2. Replies: 4
    Last Post: 04-06-2020, 11:48 PM
  3. [SOLVED] How to select a option button based on a command button selection and cell value
    By machoman4lyf in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-14-2018, 02:19 PM
  4. Replies: 2
    Last Post: 02-02-2016, 10:27 PM
  5. VBA code to create command button. Print all sheets then delete command button.
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-15-2015, 05:18 PM
  6. [SOLVED] command button to fill color in cell based on text in another cell
    By gavwalsh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-22-2014, 03:10 AM
  7. [SOLVED] How to make a Command button run the "FORM" command to fill/populate a table?
    By jrobin7 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-21-2012, 12:26 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