+ Reply to Thread
Results 1 to 7 of 7

VBA code of not selecting array

  1. #1
    Registered User
    Join Date
    03-09-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    8

    VBA code of not selecting array

    Hi All
    One more VBA newbie... Generated the code using macros...

    I have a VBA Code

    Sub Macro16()

    Range("A1").Select
    ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields. _
    Clear
    ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields. _
    Add Key:=Range("H:H"), SortOn:=xlSortOnValues, Order:=xlAscending, _
    DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort
    .Header = xlYes
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
    End With

    'Need code here-------------Help required here......

    ActiveSheet.AutoFilter.Range.Offset(1).SpecialCells(xlCellTypeVisible).Cells(1, 2).Select
    ActiveCell.EntireRow.Select

    Range(Selection, Selection.End(xlDown)).Select
    Selection.Delete Shift:=xlUp
    ActiveSheet.Range("$A$1:$U$100").AutoFilter Field:=8
    Range("A1").Select

    I have a list of people in Column H and I need to filter in column H in such a way that except person 4 , person 5, person 8 so on for 10 people rest of them should be selected so that my code can filter out other people mentioned and delete from excel sheet.

    I can select who I want to filter that code ran well
    but the problem who I dont want to filter because apparently we can select only 2 criteria at a time.

    Thanks for the help in advance

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,199

    Re: VBA code of not selecting array

    Hi, harpyaph,

    how will you determine which people shall not be shown on the filtering? You could use the Advanced Filter started on a differennt sheet to narrow down the result with a criteria range.

    Maybe it would be a good idea to attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

    And could you please wrap your code in Code-Tags? Thanks.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    03-09-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: VBA code of not selecting array

    For Forum.xlsx

    Hi
    Thank you for the reply.

    I have attached an Excel sheet that shows the Before and after data.
    In column A the data is varying.
    But Person 1,3,4,7,8 is constant.
    And Column A is much more random in the sense it will not be in order.
    I have shown it for just representation.

    Thanks again
    Hope to get the solution soon

    Regards

  4. #4
    Registered User
    Join Date
    03-09-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: VBA code of not selecting array

    Hi Holger

    For code tags is this how we are supposed to do it?
    -->
    Please Login or Register  to view this content.
    Is this close?

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,199

    Re: VBA code of not selecting array

    Hi, harpyaph,

    close as you can get - right on the money

    IŽll have a look at your workbook right away and most hopefully be back very shortly.

    Ciao,
    Holger

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,199

    Re: VBA code of not selecting array

    Hi, harpyaph,

    I mad a list of names to appear on Sheet2 starting in A1 down and used the following code to filter the data on Sheet1 Column A:

    Please Login or Register  to view this content.
    Ciao,
    Holger

  7. #7
    Registered User
    Join Date
    03-09-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: VBA code of not selecting array

    Hi Holger

    Thank you very much that worked really well

    I hope i can combine it with the rest of the code...

    Regards
    Pavan

+ 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