Results 1 to 12 of 12

Copy only Used Parts of a Range

Threaded View

  1. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Copying only Used Parts of a Range

    Hello someone3426,

    Copy the macro into a VBA module and then add a button to your worksheet and attach the macro to it.
    Sub CopySkills()
    
      Dim DstRng As Range
      Dim I As Long
      Dim N As Long
      Dim SrcRng As Range
      
        Set SrcRng = Worksheets("Design").Range("A121:A218")
        Set DstRng = Worksheets("Character Sheet 1").Range("BI16")
         
         N = 16
         For I = 1 To SrcRng.Rows.Count
           If SrcRng.Cells(I, 2) <> 0 Then
              DstRng.Offset(N, 0) = SrcRng.Cells(I, 1)
              DstRng.Offset(N, 21) = SrcRng.Cells(I, 2)
              N = N + 2
           End If
         Next I
         
    End Sub
    Last edited by Leith Ross; 12-21-2009 at 02:58 PM. Reason: Forum doesn't like the letters C & D together, Replaced columns with numbers
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

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