+ Reply to Thread
Results 1 to 9 of 9

Help adding Copy PasteSpeical to VBA

  1. #1
    Registered User
    Join Date
    03-27-2017
    Location
    Dubai
    MS-Off Ver
    Excel 2013
    Posts
    18

    Help adding Copy PasteSpeical to VBA

    Hi,

    I have the following code, which aims to save my workbook as an xlsx file and then email to a colleague. The problem is that it corrupts the data in the sheet, so I would like to add a PasteSpecial Paste:=xlPasteValuesAndNumberFormats argument.

    Current code:

    Please Login or Register  to view this content.
    If someone can help me copy the contents of the ActiveSheet and Paste Special numbers and formats, before the email is sent, that would be great.

    Thanks,

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Help adding Copy PasteSpeical to VBA

    I think all you may need is to add this to convert the formulas to values before saving.

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 04-17-2017 at 03:12 AM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    03-27-2017
    Location
    Dubai
    MS-Off Ver
    Excel 2013
    Posts
    18

    Re: Help adding Copy PasteSpeical to VBA

    Hi,

    This still leave me with errors unfortunately. The worksheet before running the macro looks like this:

    2017-04-12 08_14_27-Abdur Morning Update - Excel.png

    Once emailed and opened like this:

    2017-04-12 08_14_45-Morning Update 12-Apr-17 [Read-Only] - Excel.png

    I think therefore that I need the code to PasteValuesAndNumberFormats, then send with only the values and formats, no underlying codes.

    Is this possible to achieve?

    Thanks

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Help adding Copy PasteSpeical to VBA

    Try:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-27-2017
    Location
    Dubai
    MS-Off Ver
    Excel 2013
    Posts
    18

    Re: Help adding Copy PasteSpeical to VBA

    Hi,

    The code gets stuck on:

    2017-04-17 16_31_49-Microsoft Visual Basic for Applications - Abdur Morning Update.xlsm [break] .png

    Do you know how I can modify? I been struggling to get this to work for a while.

    Appreciate the help,

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,364

    Re: Help adding Copy PasteSpeical to VBA

    Please Login or Register  to view this content.
    Last edited by bakerman2; 04-17-2017 at 09:27 AM.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  7. #7
    Registered User
    Join Date
    03-27-2017
    Location
    Dubai
    MS-Off Ver
    Excel 2013
    Posts
    18

    Re: Help adding Copy PasteSpeical to VBA

    Hi,

    It now causes Excel to crash and close:

    Please Login or Register  to view this content.
    Any ideas why?

    I would just like to the code to copy and paste the values and then email the workbook.

    Any ideas?
    Thanks

  8. #8
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Help adding Copy PasteSpeical to VBA

    you should put the loop after you do the copy (like in alphafrogs' code)
    otherwise your main spreadsheet will be hard coded with values and formulas lost (if there are any)
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  9. #9
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Help adding Copy PasteSpeical to VBA

    looking at the picture
    how is your spreadsheet update? do you have a data connection of some kind?

+ 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. Copy last two columns and adding them to the right (the end) - progressively
    By potthoffw in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-09-2016, 01:36 PM
  2. [SOLVED] Automatically copy formula when adding row
    By sarmadamidi in forum Excel General
    Replies: 6
    Last Post: 01-14-2016, 12:36 PM
  3. Copy Data from Sheet to same row or adding new row
    By MoldyBread in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-18-2014, 10:46 AM
  4. Help With Current Macro Adding Copy Over
    By gaspower in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-21-2013, 07:09 PM
  5. Help with adding a button to Excel to copy row of cells
    By watido88 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-26-2012, 05:17 PM
  6. Multiple Copy and Paste with Adding
    By carluk in forum Excel General
    Replies: 2
    Last Post: 11-28-2008, 12:37 PM
  7. [SOLVED] copy formula with adding e.g. 10 cells
    By René in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-10-2005, 06:05 AM

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