Forum Discussion

A_SIRAT's avatar
A_SIRAT
Iron Contributor
Nov 22, 2022

Request with a Macro and VBA

Hi,   I would like to be assisted with a vba code/macro to accomplish below.  I have attached a sample workbook.   1. The macro to hide all blanks rows ( deselect hyphen only) under " Description...
  • HansVogelaar's avatar
    Nov 22, 2022

    A_SIRAT 

    Assuming that you want to save each sheet separately:

     

    Sub HideAndSave()
        Dim wb As Workbook
        Dim ws As Worksheet
        Dim f As Variant
        Application.ScreenUpdating = False
        Application.DisplayAlerts = False
        Set wb = ActiveWorkbook
        For Each ws In wb.Worksheets
            ws.Range("B14").AutoFilter Field:=1, Criteria1:="<>-"
            ws.Copy
            Application.Dialogs(xlDialogSaveAs).Show ws.Range("K11").Value & ".xlsx"
            ActiveWorkbook.Close SaveChanges:=False
        Next ws
        Application.DisplayAlerts = True
        Application.ScreenUpdating = True
    End Sub

Resources