Is it the last column that has ANY empty data in it? Or is at ALL data in the column is empty?
Either way, you’ll want to loop through the columns in reverse order. In normal programming this would be done by something like
For dt1.columns.count-1 to 0 step -1 but Uipath doesn’t have a For loop activity (only for each) which allows you to step through backwards, so you have to approximate it by using a while loop.
You can use a loopcounter and index in the while loop and at the end of the loop just subtract 1 from the loopcounter and index. It would then be something like:
While loopcounter > 0 [do code here] assign loopcounter = loopcounter - 1
So with the looping stuff out of the way, you have to figure out what code to include in the loop. This thread has a decent way of checking here: How to check if a particular column is empty in DataTable (Without using For Each Row)?
Once you find a column that is completely empty, you can use the datacolumn.Ordinal() property to determine the position of the empty column. This gives an integer. With that integer, you can then convert into a letter (if needed), or just write directly to that column instead