Results 1 to 5 of 5

Limit the number of rows that get copied.

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Talking Limit the number of rows that get copied.

    Hello!

    This code copies the values from selected rows of Sheet1 to another sheet ("Labels")

    If the Labels destination row is 14 or greater, I don't want the copy operation to work.

    What is the best way to modify this code to do that? Maybe even a message box that says "You already have 12 labels prepared on the Label sheet."?

    Private Sub btnEditLabels_Click()
    Dim ce As Range
       For Each ce In Range("A8:A" & Cells(Rows.Count, 1).End(xlUp).Row)
            If Not IsEmpty(ce) Then
            With Sheets("Labels")
                .Unprotect "SECRET"
                .Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Resize(1, 17).Value = Range(ce, ce.Offset(0, 16)).Value
                ce.ClearContents
                .Select
                .Protect "SECRET"
                End With
            End If
        Next ce
    End Sub
    I appreciate the help!

    Respectfully,

    Lost
    Last edited by leaning; 08-12-2011 at 04:29 PM. Reason: Solved!!

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