Closed Thread
Results 1 to 9 of 9

How to create a conditional macro so it doesn't erase my work?

  1. #1
    Forum Contributor
    Join Date
    02-18-2020
    Location
    Ottawa, ON
    MS-Off Ver
    Professional Plus 2010
    Posts
    139

    Angry How to create a conditional macro so it doesn't erase my work?

    Hi there,

    I have been creating a worksheet for personal use that will track my project management duties much better than paper can. I have a row of information followed by a huge checklist for each project I am working on. Every time I have a new project, I need to enter all of this data again, so I created a separate sheet that includes a template that I can easily copy and paste under my current project row. My issue is this:

    I have tried to create a macro that goes into the template sheet, copies the cells, goes back to the project management sheet and pastes the template under my current work. The problem is that the macros always does exactly as I did, instead of ALWAYS pasting it one row beneath my current project, it will paste it in the exact spot every time, which will erase my data after I've input another row already.

    I hope I have explained this well enough. How can I create a conditional macro to always paste the template BELOW my already input work?

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

    Re: How to create a conditional macro so it doesn't erase my work?

    It would be easier to help if you could attach a copy of your file. See the yellow banner at the top of this page.
    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
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: How to create a conditional macro so it doesn't erase my work?

    The general approach is to use a line of code like this to find out where your existing data ends:

    where w is the worksheet where you are pasting (not necessary if the code is in the module for that worksheet).

    Please Login or Register  to view this content.
    If you provide all your existing code, or better yet, the file (see yellow banner at top of page), we can give a solution specific to your situation.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Forum Contributor
    Join Date
    02-18-2020
    Location
    Ottawa, ON
    MS-Off Ver
    Professional Plus 2010
    Posts
    139

    Re: How to create a conditional macro so it doesn't erase my work?

    I will erase my data and post it here so that you can better understand it. This seems like a solution that will work, though I don't exactly understand the code you have posted. If I record the macros as usual, will I just have to go in and change some of the code or is a completely different process?
    Last edited by AliGW; 02-18-2020 at 02:04 PM. Reason: Please don't quote unnecessarily!

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: How to create a conditional macro so it doesn't erase my work?

    I am not sure what you are describing in terms of recording the macros--which macros will you be recording? The code I wrote cannot be generated by recording a macro, if that's what you mean.

    P.S. You can reply to a post without quoting it. In fact, we prefer it, unless there is something specific in the post you need to refer to.

  6. #6
    Forum Contributor
    Join Date
    02-18-2020
    Location
    Ottawa, ON
    MS-Off Ver
    Professional Plus 2010
    Posts
    139

    Re: How to create a conditional macro so it doesn't erase my work?

    Sorry about that. So I have uploaded the file and reposted the question, if you want to take a look at it.

    Basically what I did was record a macro going into another worksheet (B), copying a bunch of cells that include a header (with project info) and a checklist beneath it. I then return to the first worksheet (A) and paste those copied cells beneath my current work. I recorded this because I want to be able to just click a button to create a new blank row (with all of the header information and checklist included) rather than having to go into worksheet B and copy&paste them every single time. Hope this helps explain a little better.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: How to create a conditional macro so it doesn't erase my work?

    Quote Originally Posted by Keegan1116 View Post
    Sorry about that. So I have uploaded the file and reposted the question, if you want to take a look at it.
    The file is not posted to this thread and I don't see another thread on this. We would much prefer if you attach your file in this thread rather than starting a new thread with the same question.

    If the macro is already recorded, then we just need to adjust the existing macro, using the strategy I described. Also, the macro recorder often results in bloat that can be cleaned up.

    As a new member I suggest you take 1 minute to review our rules. There aren't many, and they are all important.

  8. #8
    Forum Contributor
    Join Date
    02-18-2020
    Location
    Ottawa, ON
    MS-Off Ver
    Professional Plus 2010
    Posts
    139

    Re: How to create a conditional macro so it doesn't erase my work?

    Here is the link to the post where I posted the file:

    https://www.excelforum.com/excel-pro...ml#post5280572

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: How to create a conditional macro so it doesn't erase my work?

    Well, this is why I suggested you read the rules.

    Administrative Note:

    Welcome to the forum.

    Unfortunately, this is a duplicate thread, and you are allowed only ONE thread per issue here.

    Please see Forum Rule #5 about thread duplication.

    I am closing this thread, but you may continue here in the other thread

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] conditional formatting - doesn't work
    By Danny77 in forum Excel General
    Replies: 10
    Last Post: 04-25-2019, 03:07 PM
  2. Trying to create pivot using Macro - doesn't work?!?
    By syim in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-21-2014, 01:28 PM
  3. [SOLVED] Macro work in personal workbook, doesn't work in other workbooks
    By Centexcel in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-30-2013, 11:47 AM
  4. [SOLVED] Macro Doesn't Work Through Button, Does Work Through Developer ->Macros Option
    By freybe06 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-27-2013, 11:55 AM
  5. Macro that should create csvs of all the sheets of a workbook doesn't work! help!
    By scantron in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-15-2012, 12:46 PM
  6. Excel 2007 : AND doesn't work in Conditional Formatting
    By cellarir in forum Excel General
    Replies: 2
    Last Post: 03-21-2012, 06:10 PM
  7. [SOLVED] why doesn't my conditional formula work?
    By jake in forum Excel General
    Replies: 3
    Last Post: 03-07-2005, 02:06 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