+ Reply to Thread
Results 1 to 9 of 9

Macro to backup data in separate sheet

  1. #1
    Forum Contributor
    Join Date
    08-21-2011
    Location
    Australia, Perth
    MS-Off Ver
    Excel 2010
    Posts
    159

    Macro to backup data in separate sheet

    Hi folks,

    I'm having some problems writing a macro to backup a range on a hidden sheet (changing in length) onto another hidden sheet.

    I have attached an example of what I'm trying to achieve:
    • copy all lines with content other than "" from columns A to C in "Live" sheet (you'll note that this sheet imports from another one hence the <>"")
    • paste values only in the next available line on sheet "Backup", starting in column C
    • tricky part that I don't know how to go about: insert in column B for the range that has just been pasted the start of the current week date in the format "dd-mmm" as text and in column A concatenante this date and the content of the next column.


    Please Login or Register  to view this content.
    Can anyone help me with this?

    Thanks,
    S
    Attached Files Attached Files
    Last edited by SubwAy; 07-04-2016 at 03:03 AM.

  2. #2
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: Macro to backup data in separate sheet

    Maybe like this?

    Please Login or Register  to view this content.
    Regards,
    Stephen

    If you feel someone has helped you please thank them and click on the star on their post to add reputation.
    Please ensure that you use code tags where relevant, and mark solved threads as solved.
    Most of all please be respectful and understanding of others.

  3. #3
    Forum Contributor
    Join Date
    08-21-2011
    Location
    Australia, Perth
    MS-Off Ver
    Excel 2010
    Posts
    159

    Re: Macro to backup data in separate sheet

    I may be doing this wrong but nothing happens at all when I run the code

  4. #4
    Forum Contributor
    Join Date
    08-21-2011
    Location
    Australia, Perth
    MS-Off Ver
    Excel 2010
    Posts
    159

    Re: Macro to backup data in separate sheet

    Hi spitefireblue,

    So I was obviously doing something wrong It does copy the data but it also copies the blanks (if you look on Sheet "Live" I have a formula that returns blank and the macro is selecting this and copying it.

    Also, the date and concatenate do not appear at all, any idea?

  5. #5
    Forum Contributor
    Join Date
    08-21-2011
    Location
    Australia, Perth
    MS-Off Ver
    Excel 2010
    Posts
    159

    Re: Macro to backup data in separate sheet

    Ok I'm a moron I had a selection going in the activesheet (as I was watching what was happening) and it stuffed everything.

    So, the only little glitch is that the date does not get entered as text "4-Jul" but as 4/07/2016 formatted as "4-Jul". Is there any way to change this so I have it as a text rather than a date? Also, I can't see "Date" being clearly defined so I assume that tomorrow this will change to 7-Jul, yet I need to capture the first day of the current week only. Can this be done?
    Last edited by SubwAy; 07-04-2016 at 05:13 AM.

  6. #6
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: Macro to backup data in separate sheet

    Hi Subway,
    To format the dates as text, format Column B as text and use the same code.
    To generate a start of week date use this ammended code.

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    08-21-2011
    Location
    Australia, Perth
    MS-Off Ver
    Excel 2010
    Posts
    159

    Re: Macro to backup data in separate sheet

    Hi spitfireblue,

    Thanks for spending time on this. It works perfect in my actual workbook with the exception of one thing: the two worksheets (backup and live) are hidden therefore I get a "select method of worksheet class failed" error. Is there a way to address that or do I need to abslutely have my sheets visible?

    For info, the code I now have is:

    Please Login or Register  to view this content.
    Last edited by SubwAy; 07-05-2016 at 12:15 AM.

  8. #8
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: Macro to backup data in separate sheet

    You have to make your sheets visible. But you can do that in your code...
    Please Login or Register  to view this content.
    and then hide it again at the end
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    08-21-2011
    Location
    Australia, Perth
    MS-Off Ver
    Excel 2010
    Posts
    159

    Re: Macro to backup data in separate sheet

    You sir, are a very smart cookie. thank you

+ 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] Macro to copy data from a master sheet to separate sheet as per date using a macro
    By tmaster81 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-23-2014, 08:05 AM
  2. Macro to move data from one sheet to another and separate 1 cell into 2
    By rp1783 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-26-2014, 07:18 PM
  3. Replies: 0
    Last Post: 05-21-2013, 03:09 PM
  4. Macro to separate data from one sheet to several
    By RubberBucket in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-30-2013, 05:01 PM
  5. Macro to copy data to separate excel sheet
    By eric86 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 11-27-2012, 05:16 PM
  6. I Want to store my invoice sheet in a separate sheet as backup database
    By Apurav in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-19-2012, 01:31 PM
  7. Backup files in separate directory?
    By Martyn B Tindall in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-30-2005, 08:10 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