Complex filtered data copy using VBA

war4peace

New Member
Joined
Mar 13, 2009
Messages
21
OK, this is a tricky one so please bear with me while I'm struggling to explain.
I got this large Excel table from another department and it contains about 35 columns worth of data, for a total of 150+ thousand rows. Now what they did is mess up some columns between themelves for about 17 thousand worth of rows. I have filtered he offenders out and now I need to perform a set of copy-paste actions on them, basically switching data around in columns.
I know how to copy filtered data (F5, Special, visible cells only) and that works fine. But when actually pasting over into the correct column, things start to mess up.
I have tried the following workarounds:

- simple paste. Does not work, it pastes the source over the entire destination, ignoring rows that are filtered out.
- Use F5, Special, Visible cells only on the destination, which highlights only the cells that I need to paste to, but when pasting I receive "This command cannot be performed on multiple selections". Gaah!
- Devise a macro which simply presses right, left and down keys and copies data around cell by cell. Using cell references didn't really work out well because of all the filtering (I am filtering on more than one column) so i thought I would use the SendKeys command to enforce the cell cursor movement.

Macro below:

Sub Copy_Over()
'
' Copy_Over Macro
'


'
Application.CutCopyMode = False
Selection.ClearContents
SendKeys vbKeyRight
ActiveCell.Select
Selection.Cut
SendKeys vbKeyLeft
ActiveSheet.Paste
SendKeys vbKeyDown
End Sub

The problem is that SendKeys doesn't work. Instead of moving the cursor around, it types some weird text in a cell. The text is "393740".

I am using Excel 2007.

Any help is greatly appreciated. Doing a manual copy/paste over 17 thousand rows would likely take me ages...
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,206,814
Messages
6,075,023
Members
446,114
Latest member
FadDak

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top