+ Reply to Thread
Results 1 to 10 of 10

ClearContents change to my macro

  1. #1
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    ClearContents change to my macro

    I need help to make a small change to what cells get deleted. If someone could kindly assist.

    Using the sample Excel sheet image I uploaded, the macro finds the number entered in cell A1. The first find is in cell A34, after it writes I need only cell B34 contents cleared (right now it clears B34/C34/D34). In the second example an 8 is also found in cell D20, after the write the macro deletes the contents in cells E20/F20/G20 and that’s perfect.
    Thanks in advance for your help.

    Please Login or Register  to view this content.
    EXCEL HELP FORUMN - nov 20.JPEG

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: ClearContents change to my macro

    Are you searching only columns A, D and I for the value in A1? Could you attach a copy of your file? It is hard to work with a picture.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Re: ClearContents change to my macro

    Hi

    I have uploaded my Excel sheet for your review.
    Attached Files Attached Files

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: ClearContents change to my macro

    Thanks for the file. Your code includes more than just clearing cells or a range. It also loops through columns A, D and H not just A and D and copies/pastes to column 12. Could you please describe in words exactly what you want the whole code to do. Be very detailed. If it's just a matter of finding the value of A1 in columns A and D, that's one issue but you have more going on.

  5. #5
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Re: ClearContents change to my macro

    Hi

    The operation is fine it's the following lines(at least I think) that need to be changed so that only the contents in column B get deleted and not the current B/C/D.

    '---- This clears the B/EFG/IJK columns after using the value ----
    If cell.Column = 1 Then cell.Offset(0, 1).ClearContents
    If cell.Column > 1 Then cell.Offset(0, 1).Resize(1, 3).ClearContents

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: ClearContents change to my macro

    Your macro seems to be working properly for me. It cleared only B34.

  7. #7
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Re: ClearContents change to my macro

    It's so frustrating that it only does it on my workbook. Do you know if there is something I can can do to check the cells/file/workbook?

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: ClearContents change to my macro

    If your actual file is not the same as the file you attached in Post #3, can you attach a copy of your actual file? De-sensitize it if necessary.

  9. #9
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Re: ClearContents change to my macro

    Latest update: code now works the way it should, how can that be?

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: ClearContents change to my macro

    Glad it worked out.

+ 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] VBA ClearContents
    By VAer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-15-2017, 09:30 AM
  2. [SOLVED] Range clearcontents
    By tradinup2 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-12-2013, 03:38 PM
  3. Help needed with .ClearContents
    By mhamlon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-01-2012, 02:10 AM
  4. ClearContents
    By GeneralShamu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-16-2011, 09:28 AM
  5. Speed up clearcontents macro
    By jman0707 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-04-2008, 11:39 AM
  6. ClearContents
    By tqm1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-22-2007, 08:47 AM
  7. question about ClearContents
    By Mattew in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-10-2005, 12:05 AM

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