You can't change a table (a structure of related data values stored as a bundle or nested treenodes) to a single number and retain the data.
When you have bundle data in a treenode table's cell, you can simply overwrite the cell data with a new variant:
Table("GlobalTable2").cell(2,1).value=6
If anyone finding this post wishes to toggle between treenode-based and bundle table types here's some updated code showing an example data node that is a cell within a global table (first line - this was the case in the orginal poster's model)
treenode data=Table("GlobalTable2").cell(4,1); //Global table data or other data node
int isGlobalTable=classobject(data.up)==library().find("?GlobalTable");
treenode newData;
if(getdatatype(data) != DATATYPE_BUNDLE) {
newData = nodeinsertafter(data);
nodeadddata(newData, DATATYPE_BUNDLE);
}
else if (isGlobalTable) //Copy from the library so we get our TableHeader node
newData = createcopy(library().find("?GlobalTable>variables/data"), data.up);
else { //just a node somewhere
newData = nodeinsertafter(data);
newData.value="<Treenode Table>"; // so a user can see the node contains table structure
}
data.as(Table).cloneTo(newData.as(Table));
createcopy(newData,data,1,0,0,1); // this preserves any pointers to the table that already existed in the model
destroyobject(newData);