I'm probably being lazy but was hoping some expert could tell me how to fix the code Excel created. I've tried this a few times in the past for no success, and it seems simple enough that it should be easily editable.
The above is a mess. It is defining specific cells when any normal default should be to note movements relative to start and encode them.
What I was trying to achieve was:
Start at whatever cell you are in. (Column A)
Drop down a row and cut the data in the cell there, which ought not be there.
Move back up a row and move across to 5 cells (Column F)
Paste the data there, where it should have been, instead.
Highlight the row below (from where data has just been removed).
Delete it as it is no longer of use.
The highlighted cell should now be in column A of the next line of data, i.e. one row below where we started, so that the macro can be run again on the next as yet unfixed data.
Can anyone clarify what it is I need to change in the code to stop these absolute references and turn them into relative ones ? (I'm using Office 2003 so I can't just tell it to act sensible when recording, as far as I know.)
OG, I thought we'd been through this before :-)
use offset to navigate, so offset(1,1) is one down and one to the right with negative numbers moving up and left.
So
activecell.offset(1,0).select - with cursor in A1 this will select B1
Negative numbers move up and left
etc. etc.
I felt we did and I'd assigned an icon button to it, but one day I opened Excel, the button icon had gone, and the macro had stopped working. It's the way life is these days. As I have grown older the world has become less logical, less rational. Inexplicable things happen regularly. Ho hum ...
Any thoughts on how to select the next row for deletion ? I'm unsure what Rows("2:2").Select means but it looks like an absolute reference to me. At least it doesn't sound very relative for the row below when it contains just 2s. I've tried a few things but they all crash out at run time.
Router fell off the Net for ages so wasn't able to look much up.
Sub SORT_DATA()
'
' Macro recorded 15/06/2017 by Old_Geezer
'
ActiveCell.Offset(1, 0).Select
Selection.Cut
ActiveCell.Offset(-1, 5).Select
ActiveSheet.Paste
ActiveCell.Offset(1, 0).Activate
ActiveCell.EntireRow.Delete
ActiveCell.Offset(0, -5).Select
End Sub
Yay ! Thanks. Now I have to try not to lose it again.
Sorry, we can't find any related questions. Try using the search bar at the top of the page to search for some keywords, or choose a topic and submit your own question.