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.
Bookmarks