Results 1 to 11 of 11

getting runtime error 9 with a macro to copy visible data to a summary sheets

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-11-2014
    Location
    mauritius
    MS-Off Ver
    MS365
    Posts
    1,086

    getting runtime error 9 with a macro to copy visible data to a summary sheets

    I have a subtotal for range of data (sheet name workings) , however need to copy specific columns with visible rows to another sheet called (summary ).

    See attached expected results of summary sheet in same workbook

    Looking for a vba code to copy to last data range to a new sheet in same workbook.

    As below code used but getting runtime error 9 script out of range

    Can someone assist what going wrong

    HTML Code: 


    Sub visibletotals()
    
    Dim x As Range, i As Long, y As Long, ws As Worksheet
    Set ws = ActiveSheet
    With ws
        For i = 1 To .UsedRange.Columns.Count + 1
            Select Case .Cells(1, i)
                Case Is = "Tariff No Description Origin", "Qty_1", "Litres", "Sugar", "% alcohol", "Amount", "Itemised"
                    y = .Cells(Rows.Count, i).End(3).Row
                    MsgBox Sheets("Summary").Name
                    Set x = Sheets("Summary").Rows(1).Find(.Cells(1, i), lookat:=xlValues, LookIn:=xlWhole)
                        If Not x Is Nothing Then
                            .Range(.Cells(2, i), .Cells(y, i)).SpecialCells(12).Copy Sheets("Summary").Cells(2, x.Column)
                        End If
                    Set x = Nothing
            End Select
        Next i
    End With
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] issue with a copy macro between sheets in same workbook runtime error 9
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-07-2017, 10:58 PM
  2. string macro for a user input button, copy and paste data from all sheets to summary
    By Lawleypops in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-15-2015, 11:17 AM
  3. string macro for a user input button, copy and paste data from all sheets to summary
    By Lawleypops in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-14-2015, 11:09 PM
  4. Replies: 6
    Last Post: 06-05-2014, 04:40 AM
  5. Copy Multiple Sheets produces RunTime Error
    By moxman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-09-2013, 04:13 AM
  6. Macro VBA Copy Paste Across Sheets Runtime '1004'
    By scrags in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-31-2012, 01:23 PM
  7. Copy only Visible cells to another sheet in Macro? Runtime 438 error?
    By nbaj2k in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-18-2006, 11:30 AM

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