• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

To retrieve the first column cell in a filtered table.

aggie81

Member
I want to insert the first cell in a filtered table column in the footer of a report. I found a vba code snippet from http://www.cpearson.com/excel/headfoot.htm to do the footer but I don't have a clue on where to begin with selecting the first cell in a filtered column.

Thanks for any help.

Lee
 
Hi, aggie81!


If used the built-in macro recorder to configure page printer settings you'd get a code that looks like this:

-----

[pre]
Code:
Option Explicit

Sub SetPrintHeaderAndFooter()
'
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
.PrintTitleColumns = "$A:$A"
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = ""
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = "aaaaaaaaaaaaa"
.CenterHeader = "bbbbbbbbbbbbbbbbbb"
.RightHeader = "cccccccccccccccc"
.LeftFooter = "dddddddddddddd"
.CenterFooter = "eeeeeeeeeeeeeeeeeeeeee"
.RightFooter = "fffffffffffffffffffff"
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(3.93700787401575E-02)
.BottomMargin = Application.InchesToPoints(3.93700787401575E-02)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintSheetEnd
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
Application.PrintCommunication = True
End Sub[/pre]
-----


You should only use those settings that you need, it's not necessary to keep them all. Regarding your question you could do this:

-----

.RightFooter = ActiveSheet.Cells.SpecialCells(xlCellTypeVisible).Cells(1, 1).Value

-----


Just advise if any issue.


Regards!
 
Back
Top