اذهب الي المحتوي
أوفيسنا

الردود الموصى بها

قام بنشر

جرب هذا الكود

Sub DeleteEmptyRowsAndColumns()
        x = ActiveSheet.UsedRange.Row - 1
        y = ActiveSheet.UsedRange.Rows.Count
        LastRow = x + y
Application.ScreenUpdating = False

    For r = LastRow To 1 Step -1
        If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete
    Next r
        m = ActiveSheet.UsedRange.Column - 1
        n = ActiveSheet.UsedRange.Columns.Count
        LastColumn = m + n

    For c = LastColumn To 1 Step -1
        If Application.CountA(Columns(c)) = 0 Then Columns(c).Delete
    Next c
Application.ScreenUpdating = True
End Sub

 

قام بنشر

تم التعديل حسب الطلب

Sub HideEmptyRowsAndColumns()
 UsedRange.Rows.Hidden = False
 UsedRange.Columns.Hidden = False
        x = ActiveSheet.UsedRange.Row - 1
        y = ActiveSheet.UsedRange.Rows.Count
        LastRow = x + y
Application.ScreenUpdating = False

    For r = LastRow To 1 Step -1
        If Application.CountA(Rows(r)) = 0 Then Rows(r).Hidden = True
    Next r
        m = ActiveSheet.UsedRange.Column - 1
        n = ActiveSheet.UsedRange.Columns.Count
        LastColumn = m + n

    For c = LastColumn To 1 Step -1
        If Application.CountA(Columns(c)) = 0 Then Columns(c).Hidden = True
    Next c
Application.ScreenUpdating = True
End Sub

 

قام بنشر

جرب الكود التالي عله يفي بالغرض

Sub HideEmptyRowsAndColumns()
    Dim X As Long, LR As Long
    
    With Application
        .ScreenUpdating = False
            Columns.Hidden = False: Columns.Hidden = True

            For X = 1 To Columns.Count
                If .WorksheetFunction.CountA(Columns(X)) > 0 Then Columns(X).Hidden = False
            Next X
            
            LR = Cells.SpecialCells(xlCellTypeLastCell).Row
            Rows(LR + 1 & ":" & Rows.Count).Hidden = True
            
            For X = 1 To LR
                If .WorksheetFunction.CountA(Rows(X)) = 0 Then Rows(X).Hidden = True
            Next X
            
            Application.Goto Range("A1"), True
        .ScreenUpdating = True
    End With
End Sub

 

  • Like 1
قام بنشر

أخي العزيز حماده سعد الله

بارك الله فيك وجزيت خيراً على دعائك الطيب ..

 

الحمد لله أن تم المطلوب على خير .. والحمد لله الذي بنعمته تتم الصالحات

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information