+ Reply to Thread
Results 1 to 5 of 5

Copy/paste button code work wrong

Hybrid View

  1. #1
    Registered User
    Join Date
    07-24-2013
    Location
    Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    33

    Copy/paste button code work wrong

    Hello,

    I would like to ask some1 for help.
    As you can see in the attached file I made a button to copy values from E column to A. But i need to make some changes to not copy the N/A values. I am inserting numbers to the column A (from 50-100) and i need edit them by the small formula in E column. I made the button because is necessary copy them several times, but i need make the code to recognize if there is a number or N/A so it will paste only the numbers and keep other cells blank. So the chart wont get deformed by the zeros... .
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy/paste button code work wrong

    Try this one

    Private Sub CommandButton1_Click()
      With ActiveSheet
        .Range("E1:E100").Copy
        .Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=True, Transpose:=False
        .Columns(1).Replace "#NAME?", ""
        .Columns(1).SpecialCells(4).EntireRow.Delete
      End With
    End Sub

  3. #3
    Registered User
    Join Date
    07-24-2013
    Location
    Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: Copy/paste button code work wrong

    Well it is not work how i meant. This macro you made delete all rows below 50 also the formulas i had predefined.

  4. #4
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Copy/paste button code work wrong

    Try this

    Private Sub CommandButton1_Click()
        Range("E1:E100").SpecialCells(xlCellTypeFormulas, 7).Copy
        Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=True, Transpose:=False
    End Sub
    Regards!
    =DEC2HEX(3563)

    If you like someone's answer, click the star to give them a reputation point for that answer...

  5. #5
    Registered User
    Join Date
    07-24-2013
    Location
    Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: Copy/paste button code work wrong

    Quote Originally Posted by Debraj Roy View Post
    Try this

    Private Sub CommandButton1_Click()
        Range("E1:E100").SpecialCells(xlCellTypeFormulas, 7).Copy
        Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=True, Transpose:=False
    End Sub
    Thanks Debraj it is working exactly how i meant :D

+ 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. VBA help - why does this formula copy/paste code not work?
    By help-needed in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-10-2012, 10:05 AM
  2. Copy + Paste doesn't work when I run this code...
    By wildjester in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-21-2009, 03:57 PM
  3. Copy/paste-button - wrong reference code in sheet 2
    By Krapter in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-08-2009, 05:17 AM
  4. VBA Code for Copy Paste doesn’t work
    By Shark Man in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-16-2009, 02:37 PM
  5. FIND method doesn't work in UDF. What's wrong with this code?
    By hermac@pandora.be in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-09-2005, 01:05 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