I am copying part of a row in excel and moving it left . The result is I need to delete the cell (s) I did not move at present only one. I cannot figure out how to use cut and paste which would solve the issue, as it can happen a number of times and not always in sequence keeping track of the cells to be deleted is prone to error.
Assuming I understand what you’re after, try this. It will always move the selected cells to the A cell for whatever rows are selected. So you can have a multi-row selection and it should still work.
If you have multiple selections then it works on the first selected area. That could probably be changed (with a repeat loop) if needed.
It uses the cut range
command which will also paste when given a destination range.
tell application "Microsoft Excel"
-- get selection
set xy to item 1 of (get areas of selection)
-- determine first cell of row with selection
set ab to range ("A" & first row index of xy)
-- cut selection and paste in column A of same row
cut range xy destination of cut ab
end tell
thanks I finally got what I needed yours is probably better
if CurrVal is not CheckVal then
set MoveData to value of range (get address of (get resize NextCell column size (UsedColumns)))
clear range range (get address of (get resize FirstCell column size (UsedColumns)))
set value of range (get address of (get resize FirstCell column size (UsedColumns))) to MoveData
end if
end repeat