+ Reply to Thread
Results 1 to 13 of 13

Macro Question: Leaving the cell blank but allowing the macro to run

  1. #1
    Registered User
    Join Date
    11-02-2006
    Posts
    47

    Cool Macro Question: Leaving the cell blank but allowing the macro to run

    How can I have my macro run in its cell and still allow the cell to be blank? Say I have a number, 0.99, in the cell and I want to delete it and leave it blank. I can either push "Backspace" or the delete key and it still leaves zeros. If I push the space bar it stops the macro (which I do not want to happen) and leaves the cell blank because I added a space.

    Can I still have the cell be blank yet not have it stop the macro? Thank you to anyone who can help.

    Cellar Webs

  2. #2
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363
    if your using macro
    Please Login or Register  to view this content.
    Last edited by VBA Noob; 03-15-2007 at 03:52 PM.
    Denis

    Please always attach the sample workbook without sensitive information when asking for help

    To add a module
    Press Alt + F11 (this is the Visual Basic Environment)
    Insert Menu, select Module
    Past code there
    Close Visual Basic Environment (X)

  3. #3
    Registered User
    Join Date
    11-02-2006
    Posts
    47
    Jetted,

    At the bottem of my worksheet, I right clicked "View Code." Once I was in there, I pasted this into the viewing area:


    Please Login or Register  to view this content.
    I saved it and then clicked "Run Sub/User Form." I then went back to my spread sheet and tried it out. Nothing happened. Is there something that I didn't do? Thanks for the help.

    Cellar Webs
    Last edited by Cellar Webs; 03-15-2007 at 04:02 PM.

  4. #4
    Registered User
    Join Date
    11-02-2006
    Posts
    47

    Not working

    Jetted,
    I tried the code on a new worksheet and it still isn't working. Is there something that I need to do, that maybe I'm not doing? Thanks for the help.

    Cellar Webs

  5. #5
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363
    Hi Cell

    The code provided was a generic code, if the following does not work send a small version of what you are doing in a spreadsheet.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    11-02-2006
    Posts
    47

    Cool Small version of spread sheet

    Jetted,
    Here's a small version of what I'm working on. I tried the other code you provided but it didn't work. I created a bunch of zeros on different rows. Thanks for the help.

    Cellar Webs
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    12-18-2006
    Posts
    46
    Hi,

    press ALT+11 to get into the VB Editor area. Then double click on the ThisWorkbook area, and paste the code there.

    Then, go to your sheet, and select Alt+F8 to open your macros. Select this one and run it.

    I've tried this, and it works.

    Cheers,
    Ivan.

  8. #8
    Registered User
    Join Date
    11-02-2006
    Posts
    47

    Didn't work

    Lista,

    It didn't work. I followed your instructions and this is what happened (see attachment).

    On the first sheet (Diesel), it deleted the code that I had where the zeros were. I want to be able to leave the code in there, but have the cell be blank if it equals zero.

    On the other sheets (Day1, Day2 & Day3), the code was deleted and replaced by zeros where I had an existing macro already working. And, some of my borders around the cells were deleted as well.

    Let me know if you can figure anything else out or you could post your version since you said that it worked for you.

    Thanks for the help.

    Cellar Webs
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    11-02-2006
    Posts
    47
    Lista or Jetted,
    Have you figured out the problem? I can't get it to work. Let me know if you find anything out. Thanks for the help.

    Cellar Webs

  10. #10
    Registered User
    Join Date
    11-02-2006
    Posts
    47

    Thanks

    To those of you who have looked at the attachment,

    I still can't figure this thing out. Thank you to those of you who have taken a look at the attachments. If one of you found out who to fix it, let me know. Thanks again.

    Cellar Webs

  11. #11
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363
    Sorry was away

    If your problem is not solved try this
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    11-02-2006
    Posts
    47
    jetted,
    I tried your new file and it work somewhat. When I entered a zero into the cells on "Day1" (spreadsheet) and then went to "Diesel" (one of the other spreadsheets) and clicked the "run macro" button,...the code deleted my formula that was within each cell where there was a zero. It worked in that it found the zeros and removed them, but... it removed the code completely. I still need the code to hang around so that I can enter in a different figure when needed. Also, this code needs to be able to run on the "Day1", "Day2" and "Day3" spreadsheets that already have a macro running in them.

    Thanks again for the help. It's greatly appriciated.

    Cellar Webs

  13. #13
    Registered User
    Join Date
    11-02-2006
    Posts
    47
    jetted,

    I think I'm going to ask someone I know and see if they can give me any help. If you do figure it out, let me know! Thanks again for all the help.

    Cellar Webs

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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