+ Reply to Thread
Results 1 to 9 of 9

macro to Copy paste range skip zero values

Hybrid View

  1. #1
    Registered User
    Join Date
    04-10-2010
    Location
    Abu Dhabi, UAE
    MS-Off Ver
    Excel 2003, 2007 and 2010
    Posts
    148

    Thumbs up macro to Copy paste range skip zero values

    Hi all,
    I have a range of numbers AL5:AL22 (there is data below AL22) with no blanks but with zeros sometimes, appreciate providing a macro to copy this range (AL5:AL22), skip the cells with zero values and paste special (value) to the range A12.

    Thanks
    Last edited by Ralem; 05-25-2012 at 03:54 PM.
    Cheers
    Ralem

  2. #2
    Registered User
    Join Date
    04-10-2010
    Location
    Abu Dhabi, UAE
    MS-Off Ver
    Excel 2003, 2007 and 2010
    Posts
    148

    Re: macro to Copy paste range skip zero values

    Heeeelp!

    If unclear please let me know...

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

    Re: macro to Copy paste range skip zero values

    Hi Ralem,

    Let's say you have this in the range starting with AL5

          AL
      5   1 
      6   2 
      7   0 
      8   0 
      9   5
    In A12 you want

           A
      12   1
      13   2
      14   5
    HTH
    Regards, Jeff

  4. #4
    Registered User
    Join Date
    04-10-2010
    Location
    Abu Dhabi, UAE
    MS-Off Ver
    Excel 2003, 2007 and 2010
    Posts
    148

    Re: macro to Copy paste range skip zero values

    Yes Jeffery exactly..

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

    Re: macro to Copy paste range skip zero values

    Hi Ralem,

    See if this does it for you...

    Set for AL5:AL22

    And results starting in A12

    Sub MoveNumbers()
        Dim i As Long
        Dim j As Long
        j = 12
        For i = 5 To 22
            If Cells(i, 38).Value > 0 Then
                Cells(j, 1).Value = Cells(i, 38).Value
                j = j + 1
            End If
        Next i
    End Sub

  6. #6
    Registered User
    Join Date
    04-10-2010
    Location
    Abu Dhabi, UAE
    MS-Off Ver
    Excel 2003, 2007 and 2010
    Posts
    148

    Re: macro to Copy paste range skip zero values

    Fantastic Jeffery, thank you very very much..
    Last edited by Ralem; 05-25-2012 at 03:53 PM.

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

    Re: macro to Copy paste range skip zero values

    I'm sure this is possible, but what about it would you want to see different?

    Are you saying, if AL5:AL15 were all numbers, but from AL16:AL22 they were zero?

  8. #8
    Registered User
    Join Date
    04-10-2010
    Location
    Abu Dhabi, UAE
    MS-Off Ver
    Excel 2003, 2007 and 2010
    Posts
    148

    Re: macro to Copy paste range skip zero values

    Yes, that's what I meant but realized it is the same for the macro you wrote...

    Thanks again

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

    Re: macro to Copy paste range skip zero values

    You're welcome Ralem…glad it worked for you and thanks for the feedback...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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