+ Reply to Thread
Results 1 to 30 of 30

Button click, cut and paste into another spreadsheet data that was filtered

Hybrid View

  1. #1
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Button click, cut and paste into another spreadsheet data that was filtered

    Hi Marreco,

    Try this (all in the source sheet)

    Private Sub ButtonGone(): Dim r As Long, i As Long
        If ActiveCell.Row = 1 Then Exit Sub
        Do: i = i + 1: Loop Until Worksheets("Sheet1").Range("A" & i) = ""
       With ActiveSheet
        For r = 2 To .Range("A" & Rows.Count).End(xlUp).Row
        If Rows(r).Hidden = False Then
        Exit For
        End If: Next r
        On Error GoTo OnError
        Range("A" & r).EntireRow.Cut Worksheets("Sheet1").Range("A" & i)
        Range("A" & r).EntireRow.Delete Shift:=xlUp: i = i + 1
        End With
    OnError:
        With ActiveSheet
        ShowAllData
        ActiveSheet.TextBox1.Value = vbNullString
        End With
    End Sub
    Private Sub TextBox1_LostFocus()
         FilterNow
         ButtonGone
    End Sub
    Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
         If KeyCode = Asc(vbCr) Then
             FilterNow
             ButtonGone
         End If
    End Sub
    Private Sub FilterNow()
         If Trim(TextBox1.Value) > vbNullString Then
             Range("A1").CurrentRegion.AutoFilter Field:=4, Criteria1:=TextBox1.Value
         ElseIf ActiveSheet.AutoFilterMode Then
             Range("A1").CurrentRegion.AutoFilter
         Else: Range("A1").Select
         End If
    End Sub
    Sub TestFilter()
    Range("D17").Activate
    End Sub
    Last edited by xladept; 10-13-2012 at 08:31 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

+ 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