Results 1 to 8 of 8

Prompt Error Messages if Row exceeded Limit

Threaded View

  1. #1
    Registered User
    Join Date
    01-06-2009
    Location
    KL, Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    57

    Prompt Error Messages if Row exceeded Limit

    Hi, I have a macro file that allow me to combine all the files in the same workbook. My problem now is to prompt an error message if my combined sheet exceeded row limit. I'm not very good in VBA and i hope someone can amend the macro file for me.

    Thank you very much

    Apple

        Sub Combine()
        Dim J As Integer
        Dim R As Long
        
        On Error Resume Next
        Sheets(1).Select
        Worksheets.Add ' add a sheet in first place
        Sheets(1).Name = "Combined"
    
        ' copy headings
        Sheets(2).Activate
        Range("A1").EntireRow.Select
        Selection.Copy Destination:=Sheets(1).Range("A1")
    
    
        
        ' work through sheets
        For J = 2 To Sheets.Count ' from sheet 2 to last sheet
            Sheets(J).Activate ' make the sheet active
            Range("A1").Select
            Selection.CurrentRegion.Select ' select all cells in this sheets
    
            ' select all lines except title
            Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
    
            ' copy cells selected in the new sheet on last line
            Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
          
        Next
    End Sub
    Last edited by Apple Ling; 07-06-2010 at 10:39 PM.

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