Pivot table and VBA

  • Thread starter Thread starter Boffita
  • Start date Start date
B

Boffita

Hi,

I have a workbook with two worksheets in it.

Worksheet "Stock Locations" has two columns of source data, A & B, an
worksheet "PT_Stock_Locations" is a Pivot Table based on column A o
the other sheet. The pivot table has two columns with column A in th
"Stock Locations" worksheet being in both the row and data of the pivo
table, and the titles of those two columns start at row 4 in workshee
"PT_Stock_Locations."

I am trying to write some VBA, where by I can start at row 5 in colum
A of "PT_Stock_Locations" worksheet (i.e. the start of the data forme
from the pivot table, and move down one row in the same column. If th
cell is blank then I don't want to highlight the cell, but if it is
would like it to be highlighted. I need a loop function in this VBA s
that it will go to the bottom of column A within the pivot table unti
there is so no more data in the pivot table.

Many thanks

Boffit
 
Dim rng as Range
worksheets("PT_Stock_Locations").Activate
with ActiveSheet.PivotTables(1)
set rng = .RowRange.Columns(1).cells
for each cell in rng
if not isempty(cell) then
' not sure what you mean by highlight
cell.interior.colorIndex = 5
end if
Next
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top