+ Reply to Thread
Results 1 to 3 of 3

Incomplete Range

Hybrid View

  1. #1
    Registered User
    Join Date
    03-20-2007
    Posts
    89

    Question Incomplete Range

    Help --

    I have been trying to create a Yearly Summary Sheet. I am not experienced in VB, but I was directed to this help page:
    http://www.rondebruin.nl/copy2.htm

    It sort of worked. I managed to modify it enough to get the headers that I wanted, to only count the visible pages, etc...

    I cannot get it to read the correct range or all of the information.

    I would like the information contained in all the pages in C2:J2 (and then C3:J3, etc...)

    I would like the results to read:

    A:1 -- Sheet Name
    A:2 -- would be C2 from the other sheets

    So on ....

    Help me please.

    Thank you, Stephanie
    Attached Files Attached Files

  2. #2
    Forum Contributor boylejob's Avatar
    Join Date
    02-22-2007
    Location
    Forest City, NC
    MS-Off Ver
    2003
    Posts
    562
    Stephanie,

    See if this gives you what you are wanting. I have simply made a few modifications to your code. If it is not exactly what you are wanting, let me know and we can continue to modify until it is what you want.

    Sub Test2()
        Dim sh As Worksheet
        Dim DestSh As Worksheet
        Dim Last As Long
        Dim shLast As Long
        Dim lRow As Long
    
        With Application
            .ScreenUpdating = False
            .EnableEvents = False
        End With
    
        'Delete the sheet "YearSheet" if it exist
        Application.DisplayAlerts = False
        On Error Resume Next
        ThisWorkbook.Worksheets("YearSheet").Delete
        On Error GoTo 0
        Application.DisplayAlerts = True
    
        'Add a worksheet with the name "YearSheet"
        Set DestSh = ThisWorkbook.Worksheets.Add
        DestSh.Name = "YearSheet"
         DestSh.Cells(1, 1).Value = "Month"
          DestSh.Cells(1, 2).Value = "Instructor"
           DestSh.Cells(1, 3).Value = "Department"
            DestSh.Cells(1, 4).Value = "Duration"
             DestSh.Cells(1, 5).Value = "Topic"
              DestSh.Cells(1, 6).Value = "Workshop"
     'loop through all worksheets and copy the data to the DestSh
        For Each sh In ThisWorkbook.Worksheets
            If sh.Name <> DestSh.Name And sh.Visible = True Then
                Last = LastRow(DestSh) + 1
                DestSh.Cells(Last, "A").Value = sh.Name
                shLast = LastRow(sh)
                For lRow = 2 To shLast Step 1
                    sh.Range(sh.Cells(lRow, 3), sh.Cells(lRow, 10)).Copy
                    With DestSh.Cells(Last, 2)
                       .PasteSpecial xlPasteValues, , False, False
                       .PasteSpecial xlPasteFormats, , False, False
                       Application.CutCopyMode = False
                    End With
                    Last = Last + 1
                Next lRow
    
            End If
      Next
      
      Application.Goto DestSh.Cells(1)
      
        With Application
            .ScreenUpdating = True
            .EnableEvents = True
        End With
    End Sub
    Sincerely,
    Jeff

  3. #3
    Registered User
    Join Date
    03-20-2007
    Posts
    89

    Thumbs up That Worked

    Jeff,

    Thank you for the modification. It worked.

    Much Apprecieated.

    Stephanie

+ 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