@osbornx22: Okay. Let me try and rephrase my previous post. 
You're not dispelling yourself because your solo environment is not defined. Just setting your group to solo does nothing.
The same goes for dispelling yourself in a raid or group environment, because you're not counted among the returns of GetNumGroupMembers().
Secondly, it's not working because you're using some lua-only references, such as type for instance causing an endless loop through members without acquiring a target to dispel.
Thirdly, you wanted to know if there is some faster way of doing what you're trying to achieve. If it looks more pretty than your code, be that as it may, it's still 119% faster and allows you to quickly populate and update a spell debuff list, a debuff blacklist and dispel types without having to do any major rewriting to the code as new tiers are released or you want to add more debuffs to the blacklist.
PHP Code:
-- Dispel to use
PQ_Cleanse = 4987
-- Group setting
if IsInRaid() then group = "raid"
elseif IsInGroup() then group = "party" end
if GetNumGroupMembers() > 0 then
-- Loop party or raid members
for i=1,GetNumGroupMembers() do
local debuffCount = 0 -- Set the counter to zero
local maxCount = 0 -- Max debuffs to look for
local member = group..i
PQR_CustomTarget = "player" -- Set our default target to Player
-- Do not dispel these spells
local blackList = {33786,131736,30108,30108,124465,34914}
-- Dispel Type
local dispelType = {Magic,Disease,Poison}
-- At any given time, we can only have a total of 40 debuffs
for i=1,40 do
-- Loop our dispelTypes
for x=1,#dispelType do
-- Only fetch debuffs matching dispelType
if select(5,UnitDebuff(member,i)) == dispelType[x] then
-- If it's blacklisted, don't dispel it
for i=1,#blackList do
if UnitDebuff(member,blackList[i]) then return false end
end
-- At this point, we have cross referenced everything - Proceed
-- Check if Cleanse is in range, off cooldown and not out of sight
if IsSpellInRange(GetSpellInfo(PQ_Cleanse),member) == 1
and not PQR_IsOutOfSight(member)
and PQR_SpellAvailable(PQ_Cleanse) then
-- Count debuffs
debuffCount = debuffCount + 1
-- if the number of count is equal or greater to maxCount, return true
if debuffCount >= maxCount then
PQR_CustomTarget = member
return true
end
end
end
end
end
end
end
This should properly count the amount of debuffs you have on you as well as setting your target properly. Again, I have no way of testing it as I don't have a high level Paladin to test it on.
Remember to set Spell ID to Cleanse's Spell ID and Target to Custom.
Alternatively, you can try and replace
PHP Code:
for k = 1, 40 do
local name, rank, icon, count, type = UnitDebuff(mem,k)
if type == "Poison"
or type == "Disease"
or type == "Magic"
then
PQR_CustomTarget = mem
return true
end
end
with this
PHP Code:
for k = 1, 40 do
local dispelType = select(5,UnitDebuff(mem,k))
if dispelType == "Poison"
or dispelType == "Disease"
or dispelType == "Magic"
then PQR_CustomTarget = mem return true end
end
Hope that clears up any confusion and that I was of any help at all. 
I updated the code for a Holy Paladin's Cleanse and tried to document every step in my own code.