Finding Matching Pivot Datafield
Set PvtTable = Worksheets("Wkly Renewals") _
.PivotTables("PivotTable4")
For Each pvtfield In PvtTable.DataFields
'Value from the datafield of the pivottable
TrmVal = Trim(Mid(pvtfield, 6))
With Worksheets("Wkly Renewals").ListBox1
For i = 0 To .ListCount - 1
If lcase(.List(i)) = lcase(TrmVal) Then
.Selected(i) = True
Exit For
End If
Next
End With
Next
--
Regards,
Tom Ogilvy
"Todd Huttenstine" wrote in message
...
Tom
lol were you thinking the number 72??? Sorry I hope you
didnt take my last post the wrong way. I was not
criticizing your help at all. I was looking back over the
code and the range indeed has no use so I took it out. I
had a bite to eat and then came back and got it working.
Here is what I was trying to do. See below:
'Clears all checks from Listbox1
With Worksheets("Wkly Renewals").ListBox1
For i = 0 To .ListCount - 1
.Selected(i) = False
Next i
End With
Set PvtTable = Worksheets("Wkly Renewals").PivotTables
("PivotTable4")
For Each pvtfield In PvtTable.DataFields
'Value from the datafield of the pivottable
TrmVal = Trim(Mid(pvtfield, 6))
With Worksheets("Wkly Renewals").ListBox1
For i = 0 To .ListCount - 1
On Error Resume Next
'Vlaue from the listbox
ListValue = .List(i)
' j = WorksheetFunction.Match(ListValue,
TrmVal, 0)
' If j Is Nothing Then
If ListValue = TrmVal Then
.Selected(i) = True
Else
End If
Set j = Nothing
Next
End With
Next
-----Original Message-----
I doubt the limitation is any changes I suggested to your
code code. They
were all pertinent to what could be garnered from your
meager attempts. It
is unclear why you are trying to use find on a range if
you want to check
the listbox - that relation is known only to you. I
assumed there was some
reason to set trmVal, but you never use it, so that
remains a mystery as
well. You can rest assured, that if I had to solve this
problem, I wouldn't
need to involve you in a discussion of what approach to
use. Here is a
similar question to yours which you might be able to
provide some assistance
on. I am thinking of a number between 1 and 100
(inclusive). Can you guess
what it is?
--
Regards,
Tom Ogilvy
|