Results 1 to 2 of 2

Please help with these two Macro, add hidden cell in target row

Threaded View

sfs4c03 Please help with these two... 01-08-2013, 01:53 AM
sfs4c03 Re: Please help with these... 01-08-2013, 05:43 PM
  1. #1
    Registered User
    Join Date
    01-07-2013
    Location
    sydney
    MS-Off Ver
    Excel 2007
    Posts
    4

    Smile Please help with these two Macro, add hidden cell in target row

    Hi

    I have a macro to automatically copy last row's formula to the new row. It will work even I have hidden some columns with formula

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
        Dim LastRow As Long
    
        If Not IsEmpty(Target) Then Exit Sub
        LastRow = Cells(Cells.Rows.Count, 10).End(xlUp).Row
        If Target.Row <> LastRow + 1 Then Exit Sub
    
        Application.ScreenUpdating = False
            Rows(Target.Row - 1).Copy Rows(Target.Row)
            On Error Resume Next
            Target.EntireRow.SpecialCells(xlConstants).ClearContents
        Application.ScreenUpdating = True
    
    End Sub
    It works good until I added a combobox for autofilter. Both Macro work well when I used in different workbook. But when I put it together (same worksheet).
    An error comes out with the above macro: that command cannot be used on multiple selections - I discovered those hidden columns are no longer able to select and copy.

    The autofilter I used are as follow

    Private Sub ComboBox2_Change()
        If Sheets("All Report").Range("C31").Text = "View All" Then
            Sheets("All Report").Range("A42").AutoFilter Field:=11, Criteria1:="<>", Operator:=xlOr, Criteria2:="="
        Else
        Sheets("All Report").Range("A42").AutoFilter Field:=11, Criteria1:=Sheets("All Report").Range("B31").Text, Operator:=xlOr, Criteria2:="="
        End If
    End Sub
    Please advise how should I fix this issue

    Thank you
    Patrick

    Moderator's Edit: Use code tags when posting code. To do so in future, select your code and click on the # icon at the top of your post window.
    Last edited by sfs4c03; 01-08-2013 at 05:52 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