+ Reply to Thread
Results 1 to 2 of 2

vba cut and paste

Hybrid View

  1. #1
    Todd
    Guest

    vba cut and paste

    i have golf records on sheet 1 in column A i have course name scores, putts,
    ect. in the adjacent columns. I need a vba code to cut and paste each course
    data on a different sheet. For example have all of Course 1 data on sheet 2
    all of Course 2 data on sheet 3 ect.

    Please help
    Todd

  2. #2
    Registered User
    Join Date
    05-26-2005
    Posts
    9
    Ideally your code should do the following!
    1. first do an auto filter on the main sheet which contains all the data.
    This can be done by code similar to

    Selection.AutoFilter Field:=ColNum, Criteria1:=FiltCriteria

    2. copy the filtered data to another sheet.

    Sub CopyFilter()
    Dim Rng As Range, FiltRng As Range
    With ActiveSheet.AutoFilter.Range
    On Error Resume Next
    Set FiltRng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
    .SpecialCells(xlCellTypeVisible)
    On Error GoTo 0
    End With
    If FiltRng Is Nothing Then
    MsgBox "No Records Found"
    Else
    'clear report range (modify this suitably)
    Worksheets("Report").Range("A4:K" & Cells(Rows.Count, 2).End(xlUp).Row).Clear

    'filter and copy to report sheet
    Set Rng = ActiveSheet.AutoFilter.Range
    Rng.Offset(1, 0).Resize(Rng.Rows.Count - 1).Copy _
    Destination:=Worksheets("Report").Range("A4")
    End If
    'remove auto filter from main sheet
    ActiveSheet.ShowAllData
    End Sub



    If you are not sure, do a search for Autofilter+help!

+ 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