+ Reply to Thread
Results 1 to 15 of 15

Skip Blank Values With PasteSpecial in Excel VBA

  1. #1
    Registered User
    Join Date
    03-04-2017
    Location
    NY, NY
    MS-Off Ver
    2016
    Posts
    18

    Skip Blank Values With PasteSpecial in Excel VBA

    I posted this question on Stack Overflow here, but I haven't received a response. I'd appreciate any help, since I feel like I've tried everything I can find online.

    Here is my VBA code to copy cells from about 30 sheets and paste them all onto one sheet. Each sheet has Formulas in 4 columns that show a value if there is a value in another sheet. Like this:

    =IF(Sheet1!A2<>"", Sheet1!A2, "")

    Then I run my macro on the page that I want it to output:


    Please Login or Register  to view this content.


    The output results in a lot of blank cells after the ones with actual values in them.

    I tried putting that "SkipBlanks" variant in there, but that wasn't the solution. Any help would be appreciated.
    Last edited by Tambe257; 05-27-2017 at 01:24 PM. Reason: Added Code tags

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Skip Blank Values With PasteSpecial in Excel VBA

    Your solution is simple.

    Insert the code tags so that I can help you.


    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Last edited by mehmetcik; 05-25-2017 at 04:36 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    03-04-2017
    Location
    NY, NY
    MS-Off Ver
    2016
    Posts
    18

    Re: Skip Blank Values With PasteSpecial in Excel VBA

    I added the code tags, sorry! Now that I know I'll be sure to do that in the future

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Skip Blank Values With PasteSpecial in Excel VBA

    Add this to your code.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-04-2017
    Location
    NY, NY
    MS-Off Ver
    2016
    Posts
    18

    Re: Skip Blank Values With PasteSpecial in Excel VBA

    Since you said, "Add this to your code", I literally added it to the existing code like this:

    Please Login or Register  to view this content.
    What the result ended up being is that it inserted test onto the last line of each worksheet that it was supposed to be copying. It also pastes some data into sheet1, which it shouldn't be doing. All of the data should be pasted onto the sheet titled "Summary". This site won't allow me to upload such a large file, otherwise I'd attach a copy for your reference. If it will help I can create a smaller version and upload it. Thanks for the help!

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Skip Blank Values With PasteSpecial in Excel VBA

    Please paste the actual link to the cross post in post #1 as per the forum rules.
    HTH
    Regards, Jeff

  7. #7
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Skip Blank Values With PasteSpecial in Excel VBA

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    03-04-2017
    Location
    NY, NY
    MS-Off Ver
    2016
    Posts
    18

    Re: Skip Blank Values With PasteSpecial in Excel VBA

    Done, thanks.

  9. #9
    Registered User
    Join Date
    03-04-2017
    Location
    NY, NY
    MS-Off Ver
    2016
    Posts
    18

    Re: Skip Blank Values With PasteSpecial in Excel VBA

    mehmetcik,

    Unfortunately, there was no difference when I added that line of code. Here is a dropbox folder with a copy of the file if you're interested: https://www.dropbox.com/sh/anfqoaraa...O2oxXx_aa?dl=0
    Last edited by jeffreybrown; 05-28-2017 at 08:02 PM. Reason: Removed full quote!

  10. #10
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Skip Blank Values With PasteSpecial in Excel VBA

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    03-04-2017
    Location
    NY, NY
    MS-Off Ver
    2016
    Posts
    18

    Re: Skip Blank Values With PasteSpecial in Excel VBA

    That seems to be perfect! Thank you so much mehmetcik. If you are also a Stack Overflow user, feel free to post the answer there as well and I will mark it as correct. The link is in my initial post.
    Last edited by Tambe257; 05-30-2017 at 12:33 PM.

  12. #12
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Skip Blank Values With PasteSpecial in Excel VBA

    The solution would be for you to go to Stack Overflow and post a completion there with the link to this post.

  13. #13
    Registered User
    Join Date
    03-04-2017
    Location
    NY, NY
    MS-Off Ver
    2016
    Posts
    18

    Re: Skip Blank Values With PasteSpecial in Excel VBA

    Hi Jeffrey,
    Thanks, I know that, but I wanted to give mehmetcik the opportunity to get proper credit on SO.
    Thanks Again,
    Tony

  14. #14
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Skip Blank Values With PasteSpecial in Excel VBA

    Okay. Since I don't use SO, didn't realize there was a "credit" thing.

  15. #15
    Registered User
    Join Date
    03-04-2017
    Location
    NY, NY
    MS-Off Ver
    2016
    Posts
    18

    Re: Skip Blank Values With PasteSpecial in Excel VBA

    No problem! Yes, you earn reputation points based on positive use of the site. (answering questions, getting up votes for asking good questions, etc.) It's not the most important thing ever, but I want to make sure I give mehmetcik credit if he/she wants it.

+ 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. Excel 2007 : Skip Blank Cells While Copying A List
    By shruthitulsi in forum Excel General
    Replies: 8
    Last Post: 03-02-2015, 05:32 PM
  2. # of blank labels to skip
    By jdlc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-22-2014, 03:36 PM
  3. VB CODE FOR Excel PasteSpecial Values Only
    By medo82006 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-03-2014, 10:23 AM
  4. Pie Chart. Skip blank Horizontal Axis values
    By coreytroy in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 02-13-2013, 04:36 AM
  5. Is that possible to skip/suspend the blank values in dynamic excel chart
    By christophertpj in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 10-20-2012, 11:41 AM
  6. Insert values and skip blank rows
    By aaronprice in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-17-2009, 11:59 AM
  7. I want to copy a formula n Excel but skip any blank cells
    By Ann in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-12-2005, 03:00 PM

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