How to move the contents of a row to another row in excel. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hancre
Posts: 248
Joined: 02 Jul 2021, 20:51

How to move the contents of a row to another row in excel.

03 Aug 2021, 07:56

I handle lots of english words to make a material.
I often move the contents of a row to another row.
If the two rows are closed, I move up/down the row. ( ex. row 18 --> row 19, 20 )
but the distance is far, I should do these following actions. (ex. row 400 --> row 3000 )
1. shift + space to select a row
2. cut the contents of the row
3. remove the row
4. move to a cell in B and select the it. ( I want to search words in column B. )
4. search a word for a location for paste. (there're over 5000 words)
5. move the location for paste
6. Insert a row to the location.
7. paste the datas of the previous row to a new row.

to make it easier, I made hotkeys.
cutting works well. but paste action doesn't work.
It makes only adding a row and doesn't paste it to the new location. How can I fix the error ? ^^
Thanks for your help in advance.

pasting action :

Code: Select all

!v::
Send, {Appskey} ;menu 
Send, {I} ;insert 
Send, {Enter} 
Send, {r}  
Send, {Enter}
Send, {Shift Down}{space}{Shift up} ;select a row 
Send, ^v ;paste   
Return
cutting action

Code: Select all

!x:: 
Send, {Shift Down}{space}{Shift up}
Send, ^x ;cut 
Send, ^-  ; remove the row 
Send, {home}{right} ;move to column B
Send, ^{space} ;select the column   
Send, ^f : search a word for paste 
Return
[Mod edit: [code][/code] tags added. Please make use of them.Thank you!]

ps. I unmerged all the cells to paste well.
Last edited by gregster on 03 Aug 2021, 11:04, edited 1 time in total.
User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: How to move the contents of a row to another row in excel.  Topic is solved

03 Aug 2021, 10:17

Avoid using simulated keystrokes! Try this instead:

Code: Select all

xl := ComObjActive("excel.application")

^+x::											;cut and delete row (ctrl-shift-x)
tmp := xl.activecell.entirerow.value
xl.activecell.entirerow.delete
return

^+v::
xl.activecell.entirerow.insert					; insert and paste row (ctrl-shift-v)
xl.activecell.entirerow := tmp
return
to unmerge a range, use:

Code: Select all

xl.activecell.entirerow.unmerge					; for a row containing the active cell
or

Code: Select all

xl.usedrange.unmerge							; for the entire sheet
14.3 & 1.3.7
hancre
Posts: 248
Joined: 02 Jul 2021, 20:51

Re: How to move the contents of a row to another row in excel.

03 Aug 2021, 21:39

flyingDman wrote:
03 Aug 2021, 10:17
they work very well.
Thanks a lot for your help again.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 221 guests