Change value specified by any type to new type in Numbers

Simple example in Numbers to change a value specified by any type to new type

Could easily be adapted to some more useful or give ideas to build a Library.

tell application "Numbers"
	make new document with properties {document template:template "Simple Budget"}
	activate
end tell

(**
* [changeValueByName(string, string, integer, anything, anything)]
*)
its changeValueByName("Budget", "Expenses", 1, "Shopping", "Food")
on changeValueByName(theSheet, theTable, theColumn, oldValue, newValue)
	tell application "Numbers"
		set theDoc to front document
		tell theDoc
			tell sheet theSheet
				tell table theTable
					repeat with i from 1 to (count row)
						set currentValue to value of the cell i of column theColumn
						if currentValue contains oldValue then
							set value of cell i of column theColumn to newValue
						end if
					end repeat
				end tell
			end tell
		end tell
	end tell
end changeValueByName

This one will change the value based on category in a table in Numbers.

The category is left cell and the value is right cell

(**
* [changeValueByCategory(string, string, integer, anything, anything)]
*)
its changeValueByCategory("Budget", "Expenses", 1, "Shopping", 1000)
on changeValueByCategory(theSheet, theTable, theColumn, theCategory, newValue)
	tell application "Numbers"
		set theDoc to front document
		tell theDoc
			tell sheet theSheet
				tell table theTable
					repeat with i from 1 to (count row)
						set category to value of the cell i of column theColumn
						if category contains theCategory then
							set value of cell i of column (theColumn + 1) to newValue
						end if
					end repeat
				end tell
			end tell
		end tell
	end tell
end changeValueByCategory

This one do not use repeat loop but instead use the method: indexOfObject (ASObjC)

(**
* [changeValueByCategory2(string, string, integer, anything, anything)]
*)
its changeValueByCategory2("Budget", "Expenses", 1, "Shopping", 1000)
on changeValueByCategory2(theSheet, theTable, theColumn, theCategory, newValue)
	tell application "Numbers"
		set theDoc to front document
		tell theDoc
			tell sheet theSheet
				tell table theTable
					set theNames to its name of every row
					if theNames contains {theCategory} then
						set theIndex to ((current application's NSArray's arrayWithArray:theNames)'s indexOfObject:theCategory)
						set value of cell (theIndex + 1) of column (theColumn + 1) to newValue
					end if
					
				end tell
			end tell
		end tell
	end tell
end changeValueByCategory2

And if we have list of categorys with same amount of new values we could add a repeat loop.

(**
* [changeValuesByCategorys(string, string, integer, list of anything, list of anything)]
*)
its changeValuesByCategorys("Budget", "Expenses", 1, {"Shopping", "Transport"}, {1000, 1300})
on changeValuesByCategorys(theSheet, theTable, theColumn, theCategorys, newValues)
	tell application "Numbers"
		set theDoc to front document
		tell theDoc
			tell sheet theSheet
				tell table theTable
					set theNames to its name of every row
					if theNames contains theCategorys then
						repeat with i from 1 to (count theCategorys)
							set theIndex to ((current application's NSArray's arrayWithArray:theNames)'s indexOfObject:(item i of theCategorys))
							set value of cell (theIndex + 1) of column (theColumn + 1) to (item i of newValues)
						end repeat
					end if
					
				end tell
			end tell
		end tell
	end tell
end changeValuesByCategorys