0

I am trying to select the last cell of a pivot table. Here is the code I have now.

Can.Range("AC15") = Application.WorksheetFunction.Max(Flight)

"Flight" refers to the last cell in column D of my pivot table (my pivot table is dynamic so it is constantly changing). Right now this code works. However, is there an application.worksheetfunction that allows me to "Select" instead of finding the max?

Thanks,

G

GCC
  • 285
  • 6
  • 23
  • 1
    You don't [usually want to actually `.Select`](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba). What's the reasoning behind wanting to select it? But anyways, assuming `Flight` is a `Range`, you can do `Flight.Select` (also assuming the `Flight` range is on the activesheet). – BruceWayne Apr 02 '18 at 15:12
  • To set them equal you would do Can.Range("AC15") = Flight (assuming flight is last cell in pivot in column D – QHarr Apr 02 '18 at 15:19
  • I should add that this is a private sub. – GCC Apr 02 '18 at 16:29

1 Answers1

1

This code works, given that no content is below the pivot table in column D

Cells ( _
        'Next Row evaluates to the last used row in column "D" (so the targeted row 
        Cells(Rows.Count, "D").End(xlUp).Row, _

        'Target Column 
        "D" _
      ). Select
FloLie
  • 1,820
  • 1
  • 7
  • 19