+ Reply to Thread
Results 1 to 9 of 9

Pasting values only with VBA

  1. #1
    Registered User
    Join Date
    03-01-2016
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    47

    Pasting values only with VBA

    Hi all,

    Can someone tell me what I can change with this code so that it only pastes values?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Pasting values only with VBA

    Change

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    03-01-2016
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    47

    Re: Pasting values only with VBA

    For some reason, it isn't pasting the entire row. It is only pasting the data from the cell in column A. Any idea?

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Pasting values only with VBA

    Oops

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-01-2016
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    47

    Re: Pasting values only with VBA

    You're a wizard. Thank you

  6. #6
    Registered User
    Join Date
    03-01-2016
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    47

    Re: Pasting values only with VBA

    I still seem to have a problem with this code. The solutions you provided me seem to work perfectly, but I am finding that the code is not working consistently on all rows. basically what this code is supposed to do is copy the data from each row in the Sheet named SOR requests and paste the values into the next worksheet called Completed SOR's. This is supposed to work if the cell in column K of the SOR requests worksheet says "complete". I've tested it a few times and it for some reason this doesn't copy and paste all of the rows.

  7. #7
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Pasting values only with VBA

    I did not look at your other code - you are skipping values because when you delete a row as your code is stepping through, the row below becomes the current row, and bad things happen

    So, step backwards, and don't check all the cells of every row (and it is a bad idea to name a macro with a method's name (Copy))

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    03-01-2016
    Location
    New Jersey
    MS-Off Ver
    2013
    Posts
    47

    Re: Pasting values only with VBA

    Thank you so much. I am very new to using VBA and i am still trying to learn the basics. most of what I was using was a mix of statements I found on other forums that I pieced together to make work. I see what you are saying about the next row becoming the current row and bad things happening. Makes sense now that you pointed it out. Can I ask a stupid question, since I am new to this? Why is it a bad idea to name a macro with a method's name (Copy)? I don't quite understand that part completely

  9. #9
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Pasting values only with VBA

    It can work, but it can also lead you down weird rabbit holes, especially when you start developing large projects. If you see Copy in your code, does that mean your macro, or the method applied to an Excel object? It you type space-Copy instead of .Copy, well.....

    It's just better to avoid that issue, and use unique, descriptive names for your macros.

+ 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. Creating new workbook, pasting values, then hard coding last row values.
    By silentcarl in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-13-2015, 03:17 PM
  2. [SOLVED] Pasting values
    By grkchakri in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-05-2014, 05:24 AM
  3. [SOLVED] Help on Pasting Values
    By 2001jesper in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-21-2013, 11:40 AM
  4. Replies: 0
    Last Post: 08-13-2012, 09:09 AM
  5. pasting respectively values
    By robtai in forum Excel General
    Replies: 1
    Last Post: 05-09-2012, 07:59 AM
  6. Pasting values only
    By LDT in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-27-2010, 03:40 PM
  7. Replies: 10
    Last Post: 02-09-2010, 05:04 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