79719558

Date: 2025-07-30 07:05:28
Score: 1
Natty:
Report link

Thank you to Siddharth Rout for suggesting for me to move the rows to another worksheet. It works wonderfully now. I decided to hide the rows, then copy and paste all the values in a new sheet, then proceeded with the AutoFilter stuff that I needed to do.

 Dim wsActive As Worksheet
    Set wsActive = ActiveWorkbook.ActiveSheet
    
    'フィルターを設定
    wsActive.AutoFilterMode = False
    Rows("1:1").Select
    Selection.AutoFilter
    
'追加条件:A列が"*"有りエンドユーザーを隠します。
    
    Dim hideRow As Long
    hideRow = ActiveSheet.Cells.SpecialCells(xlLastCell).row

    For Each cell In ActiveSheet.Range("A3:A" & hideRow)
        If cell.value = "*" Then
            cell.EntireRow.Hidden = True

            Dim hiddenvalue As Variant
            hiddenvalue = ActiveSheet.Range("G" & cell.row)

            For Each othercell In ActiveSheet.Range("G3:G" & hideRow)
                If othercell.value <> "" And othercell.value = hiddenvalue Then
                    othercell.EntireRow.Hidden = True

                End If
            Next othercell

        End If
    Next cell
    
    Dim sourceWS As Worksheet
    Dim resultWS As Worksheet

    Set sourceWS = ActiveWorkbook.ActiveSheet
    Set resultWS = Worksheets.Add(After:=Sheets(Sheets.Count))

    With sourceWS
        rowEnd = .Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
        columnEnd = .Cells.Find(What:="*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column

        Set visRange = .Range("A1", .Cells(rowEnd, columnEnd)).SpecialCells(xlCellTypeVisible)
        visRange.Copy Destination:=resultWS.Range("A1")
    End With

Headache reduced thanks to the people that helped me through this.

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Blacklisted phrase (0.5): thanks
  • Blacklisted phrase (0.5): I need
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Anpo Desu