Results 1 to 4 of 4
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Not show selection in blue... (2000 sp 1)

    I have this macro to select a block of range ....
    how to not hilight in blue during the selecteion of range....(not professional, for me)
    Sub FILTRO()

    Dim FILTRO1 As String
    Dim FILTRO2 As String

    FILTRO1 = VAR_PERIODO
    FILTRO2 = DATA

    Sheets("RATIFICHE").Select

    LNGMAXROW = Range("A65536").End(xlUp).Row

    Range("A5").Select

    Selection.AutoFilter Field:=3, Criteria1:=VAR_PERIODO
    Selection.AutoFilter Field:=8, Criteria1:=DATA

    Set rng = Range("A5:J" & LNGMAXROW).SpecialCells(xlCellTypeVisible)

    rng.Select

    rng.EntireRow.Delete

    ActiveSheet.ShowAllData

    Range("A5").Select

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Not show selection in blue... (2000 sp 1)

    There is no need to select cells during this macro. For example:
    <code>
    Sub Filtro()
    Dim Filtro1 As String
    Dim Filtro2 As String
    Dim lngMaxRow As Long
    Filtro1 = Var_Periodo
    Filtro2 = Data
    With Sheets("RATIFICHE")
    lngMaxRow = .Range("A65536").End(xlUp).Row
    .Range("A5").AutoFilter Field:=3, Criteria1:=Var_Periodo
    .Range("A5").AutoFilter Field:=8, Criteria1:=Data
    .Range("A5:J" & lngMaxRow).SpecialCells(xlCellTypeVisible). _
    EntireRow.Delete
    .ShowAllData
    End With
    End Sub</code>

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Not show selection in blue... (2000 sp 1)

    One way would be to not select anything:

    <pre>Sub FILTRO()

    Dim FILTRO1 As String
    Dim FILTRO2 As String

    FILTRO1 = var_Periodo
    FILTRO2 = data

    With Sheets("RATIFICHE")
    lngmaxrow = .Range("A65536").End(xlUp).Row
    With .Range("A5")
    .AutoFilter Field:=3, Criteria1:=var_Periodo
    .AutoFilter Field:=8, Criteria1:=data
    End With

    Set rng = .Range("A5:J" & lngmaxrow).SpecialCells(xlCellTypeVisible)
    rng.EntireRow.Delete
    .ShowAllData
    .Range("A5").Select
    End With

    End Sub</pre>


    Steve

  4. #4
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Not show selection in blue... (2000 sp 1)

    You almost never have to select a range in code. In this case use:
    <pre>Option Explicit
    Sub FILTRO()
    Dim lngMaxRow As Long

    With Sheets("RATIFICHE")
    lngMaxRow = .Range("A65536").End(xlUp).Row
    With .Range("A5")
    .AutoFilter Field:=3, Criteria1:=VAR_PERIODO
    .AutoFilter Field:=8, Criteria1:=DATA
    End With
    .Range("A5:J" & lngMaxRow).SpecialCells(xlCellTypeVisible).EntireR ow.Delete
    .ShowAllData
    End With
    End Sub
    </pre>

    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •