+ Reply to Thread
Results 1 to 2 of 2

Inspect document and delete hidden rows with VBA

  1. #1
    Registered User
    Join Date
    05-01-2013
    Location
    Provo, Utah
    MS-Off Ver
    Excel 2010
    Posts
    6

    Inspect document and delete hidden rows with VBA

    Hey all,

    So I have figured out how to do a filter on rows and delete all the hidden ones (which I don't need at all) with inspect document, searching for hidden rows and columns, and deleting them, but I can't do this with a macro. I tried using the recorder and it gave me the following code, but it doesn't work. I also added the "with" statement at the end in an attempt to have it select the first empty box and then find the sum of all cells above it, but I'm not as worried about that right now. Thanks!

    Sub reviewdata()
    '
    ' reviewdata Macro
    ' This will edit out all unnecessary data to find reviewer totals and averages.
    '
    ' Keyboard Shortcut: Ctrl+Shift+Z
    '
    Columns("A:A").ColumnWidth = 22
    Columns("B:B").ColumnWidth = 22
    Columns("C:C").Select
    Selection.Delete Shift:=xlToLeft
    Columns("D:D").Select
    Selection.Delete Shift:=xlToLeft
    Columns("E:E").Select
    Selection.Delete Shift:=xlToLeft
    Columns("A:D").Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$D$214").AutoFilter Field:=2, Criteria1:= _
    "=Content Review (Article)", Operator:=xlOr, Criteria2:= _
    "=Content Review (Blog)"
    ActiveWorkbook.RemoveDocumentInformation (xlRDIPrinterPath)
    Range("E2").Select
    ActiveCell.FormulaR1C1 = "=RC[-2]*60/RC[-1]"
    Range("E2").Select
    Selection.FillDown
    With wsThis
    nNextRow = .Cells(.Rows.Count, "D").End(xlUp).Row + 1
    If nNextRow < 29 Then nNextRow = 29
    End With
    ActiveCell.FormulaR1C1 = "=SUM(R[-R+2]C:R[-1]C)"
    End Sub
    Last edited by sabutler4; 05-02-2013 at 04:52 PM. Reason: mistakenly typed element instead of document. sorry

  2. #2
    Registered User
    Join Date
    05-01-2013
    Location
    Provo, Utah
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Inspect element and delete hidden rows with VBA

    Ok, so I worked out a lot of the kinks with this code, but I still can't figure out how to make it delete the hidden rows. Here is the updated code. Any help is appreciated!

    Sub reviewdata()
    '
    ' reviewdata Macro
    ' This will edit out all unnecessary data to find reviewer totals and averages.
    '
    ' Keyboard Shortcut: Ctrl+Shift+Z
    '
    Columns("A:A").ColumnWidth = 22
    Columns("B:B").ColumnWidth = 22
    Columns("C:C").Select
    Selection.Delete Shift:=xlToLeft
    Columns("D:D").Select
    Selection.Delete Shift:=xlToLeft
    Columns("E:E").Select
    Selection.Delete Shift:=xlToLeft
    Columns("A:D").Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$D$214").AutoFilter Field:=2, Criteria1:= _
    "=Content Review (Article)", Operator:=xlOr, Criteria2:= _
    "=Content Review (Blog)"
    ActiveWorkbook.RemoveDocumentInformation (xlRDIPrinterPath)
    Range("E2").Select
    ActiveCell.FormulaR1C1 = "=RC[-2]*60/RC[-1]"
    Selection.AutoFill Destination:=Range("E2:E50"), Type:=xlFillDefault
    Columns("D:D").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "=SUM(R2C:R[-1]C)"
    End Sub

+ 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