+ Reply to Thread
Results 1 to 13 of 13

Delete Cell Contents when macro runs

  1. #1
    Registered User
    Join Date
    06-17-2013
    Location
    Salt Lake City, UT
    MS-Off Ver
    Excel 2011
    Posts
    26

    Delete Cell Contents when macro runs

    Below is my current code that is working fine. The Macro runs when I type a value into cell G2, it then adds the value of G2 to cell G4, G5, G6, G7, or G8 depending on the date. What code can I add to this so that once the macro adds G2 to the other cell, it would then delete the contents of cell G2?

    Please Login or Register  to view this content.
    Last edited by brown3218; 09-09-2013 at 11:23 PM.

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Delete Cell Contents when macro runs

    Maybe
    Please Login or Register  to view this content.
    Last edited by Solus Rankin; 09-05-2013 at 07:05 PM.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Delete Cell Contents when macro runs

    perhaps

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    06-17-2013
    Location
    Salt Lake City, UT
    MS-Off Ver
    Excel 2011
    Posts
    26

    Re: Delete Cell Contents when macro runs

    Not quite sure how to insert that into my code.

    Quote Originally Posted by Richard Buttrey View Post
    perhaps

    Please Login or Register  to view this content.

  5. #5
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Delete Cell Contents when macro runs

    Brown,

    If you don't hear from Richard try the code in post #2. I amended and included your entire code.

  6. #6
    Registered User
    Join Date
    06-17-2013
    Location
    Salt Lake City, UT
    MS-Off Ver
    Excel 2011
    Posts
    26

    Re: Delete Cell Contents when macro runs

    Thanks Solus,

    I tried your code and it worked once and then it the whole macro stopped working. I didn't get any errors, it just stopped adding the cell value to the other.

  7. #7
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Delete Cell Contents when macro runs

    I may have disabled events too soon because of the exit sub. Try
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-17-2013
    Location
    Salt Lake City, UT
    MS-Off Ver
    Excel 2011
    Posts
    26

    Re: Delete Cell Contents when macro runs

    Hmm, when I run this it gives me a syntax error and highlights If Target.Address = "$G$2"

    Quote Originally Posted by Solus Rankin View Post
    I may have disabled events too soon because of the exit sub. Try
    Please Login or Register  to view this content.

  9. #9
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Delete Cell Contents when macro runs

    This changes things up a bit, but I believe its what you're trying to achieve
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    06-17-2013
    Location
    Salt Lake City, UT
    MS-Off Ver
    Excel 2011
    Posts
    26

    Re: Delete Cell Contents when macro runs

    Sorry for all of the back and forth. I now get an error, "Compile Error: Else Without If". It Highlights this line: ElseIf Not Intersect(Target, Range("H2")) Is Nothing Then

    Quote Originally Posted by Solus Rankin View Post
    This changes things up a bit, but I believe its what you're trying to achieve
    Please Login or Register  to view this content.

  11. #11
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Delete Cell Contents when macro runs

    I missed an 'end if'
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    06-17-2013
    Location
    Salt Lake City, UT
    MS-Off Ver
    Excel 2011
    Posts
    26

    Re: Delete Cell Contents when macro runs

    Thank you thank you!

  13. #13
    Registered User
    Join Date
    06-17-2013
    Location
    Salt Lake City, UT
    MS-Off Ver
    Excel 2011
    Posts
    26

    Re: Delete Cell Contents when macro runs

    Ended up using this:

    Please Login or Register  to view this content.

+ 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. Delete Cell Value after Macro Runs
    By brown3218 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-20-2013, 11:42 AM
  2. [SOLVED] Macro to delete certain contents of a cell
    By SpyderPB6 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2012, 07:16 PM
  3. Macro to delete entire row based on cell contents
    By ATX in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-06-2011, 03:52 AM
  4. Macro to delete cell contents in every other column
    By rhudgins in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-01-2010, 12:29 PM
  5. [SOLVED] VBA Excel Macro to delete contents in named cell
    By reaa in forum Excel General
    Replies: 1
    Last Post: 01-03-2006, 04:20 PM

Tags for this Thread

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