+ Reply to Thread
Results 1 to 6 of 6

Copying Visible Cells from Autofilter with/out headings

  1. #1
    Registered User
    Join Date
    04-03-2014
    Location
    Johannesburg
    MS-Off Ver
    Excel 2007
    Posts
    19

    Copying Visible Cells from Autofilter with/out headings

    Hi

    This line of code is copying from row 3 meaning without heading and first first row of information:

    .SpecialCells(xlCellTypeVisible).Offset(1).Copy

    This line of code is copying visible cells with heading:

    .SpecialCells(xlCellTypeVisible).Copy


    I need the macro to copy the filtered cells without the heading but from the first row. For some reason the offset(1) is skipping the first row of data.

    Please help out here if you can.

    Thanks

  2. #2
    Forum Expert
    Join Date
    11-26-2013
    Location
    Colac, Victoria, Australia
    MS-Off Ver
    Excel 2016
    Posts
    1,309

    Re: Copying Visible Cells from Autofilter with/out headings

    Hi Eijaz,

    Without seeing the rest of your code and testing it, this is just a guess! Try Offset(0)! Offset(1) is taking you to the next row.

    I hope this helps, please let me know!

    Regards,

    David

    When you reply please make it clear WHO you are responding to by mentioning their name.

    If this has been of assistance, please advise. A little thanks goes a long way.
    - Please click on the *Add Reputation button at the bottom of helpful responses.

    Please mark your thread as SOLVED:
    - Click Thread Tools above your first post, select "Mark your thread as Solved".

  3. #3
    Registered User
    Join Date
    04-03-2014
    Location
    Johannesburg
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Copying Visible Cells from Autofilter with/out headings

    @ David

    It still doesnt work, here is my code, 0 offset adds the headings and 1 offset takes out the first line of information:



    Dim wbCopy As Workbook
    Dim wsCopy As Worksheet
    Dim wbPaste As Workbook
    Dim wsPaste As Worksheet

    Set wbCopy = Workbooks.Open("C:\Documents and Settings\abek276\Desktop\Book27.xlsx")
    Set wsCopy = wbCopy.ActiveSheet


    Options = InputBox(Prompt:="Scheme Code", Title:="Options")
    Options1 = InputBox(Prompt:="Scheme Code", Title:="Options")
    Options2 = InputBox(Prompt:="Scheme Code", Title:="Options")

    MyName = InputBox("Scheme Name")

    Set wbPaste = Workbooks.Add
    Set wsPaste = wbPaste.Sheets(1)

    With wsCopy
    .AutoFilterMode = False
    With .Range("A2").CurrentRegion
    .AutoFilter Field:=1, Criteria1:=Options
    .SpecialCells(xlCellTypeVisible).Copy
    wsPaste.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False


    With wsCopy
    .AutoFilterMode = False
    With .Range("A2").CurrentRegion
    .AutoFilter Field:=1, Criteria1:=Options1
    .SpecialCells(xlCellTypeVisible).Offset(1).Copy
    wsPaste.Range("A1").End(xlDown).Offset(1, 0).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False



    With wsCopy
    .AutoFilterMode = False
    With .Range("A2").CurrentRegion
    .AutoFilter Field:=1, Criteria1:=Options2
    .SpecialCells(xlCellTypeVisible).Offset(1).Copy
    wsPaste.Range("A1").End(xlDown).Offset(1, 0).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False


    End With

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copying Visible Cells from Autofilter with/out headings

    Try:

    .Offset(1).SpecialCells(xlCellTypeVisible).Copy

  5. #5
    Registered User
    Join Date
    04-03-2014
    Location
    Johannesburg
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Copying Visible Cells from Autofilter with/out headings

    Thanks John that worked well.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copying Visible Cells from Autofilter with/out headings

    You're welcome. Glad to help out and thanks for the feedback.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Pasting in Autofilter table (visible cells)
    By peter_pdj in forum Excel General
    Replies: 3
    Last Post: 09-07-2013, 05:36 PM
  2. When using Autofilter with SumIf, can not get it to sum only visible cells.
    By DitoPower in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-12-2013, 07:36 AM
  3. [SOLVED] Copy/Pasting Values from visible cells (using autofilter) to visible cells
    By evakotsi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-23-2012, 07:49 AM
  4. Rank visible cells with autofilter
    By tolio in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-16-2008, 10:16 AM
  5. Autofilter - Sum visible cells
    By BVHis in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2008, 06:01 PM

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