Row Title Code to Keep In Line With Last Column of Pivot Table

boldcode

Active Member
Joined
Mar 12, 2010
Messages
347
Hi,

I am trying to keep my Row Title that I created in line with the last column of pivot table report, but for some reason it always spills over an extra column. Here my code below and the code the for the two functions I created.
Code:
 'ActiveSheet.PivotTables("PivotTax").ShowDrillIndicators = False
    Range("A5:" & Number2Char(LastColumn) & "5").Select
    ActiveCell.Formula = "Tax Report"
    Selection.Font.Bold = True
    With Selection.Font
        .Name = "Arial"
        .Size = 14
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = 1
        '.TintAndShade = 0
        '.ThemeFont = xlThemeFontNone
    End With

    Selection.HorizontalAlignment = xlCenterAcrossSelection

Number2Char Function:

Code:
Function Number2Char(c As Integer) As String
    Number2Char = Split(Cells(1, c).Address, "$")(1)
End Function

LastColumn Function:

Code:
Function LastColumn() As Long
    Dim ix As Long
    ix = ActiveSheet.UsedRange.Column - 1 + ActiveSheet.UsedRange.Columns.Count
    LastColumn = ix
End Function
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try something like this...

Code:
    LastCol& = Cells.Find("*", , xlFormulas, , xlByColumns, xlPrevious).Column
    Range("A5", Cells(5, LastCol)).Select
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,790
Members
452,942
Latest member
VijayNewtoExcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top