Forum Discussion
How to copy columns from one sheet to another empty column in new sheet with Macros
Riny_van_Eekelen Thank you. Two issues:
When I run this, I get an error. "Run Time Error: '1004': To do this all the Merged Cells must be the same size. "
It is happening in the part of the code:
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Then the second time that I run it, instead of starting to paste in J4 (which would be the next empty column) it pastes in L4. This means that the 3rd time running it, I get an error "Run-time error '13': Type Mismatch"
This is happening when it is running this part of the code;
If TargetSheet.Range("B4") = "" Then
I really appreciate the assistance.
davidtaillefer Difficult to debug without having your file to test on. The code I provided worked in a workbook in which I tried to replicate the situation you described. With regard the to the first error, get rid of merged cells. They are the source of much "evil". Use "Format cells, Alignment, Horizontal, Center across selection" in stead (credit to Wyn Hopkins who mentioned this in a recent live session on this site). A few more clicks but it avoids the problems when working with merged cells.
Don't really understand why the same macro would run into different errors for every time it is run. So, can you upload your file (without any confidential information, that is)?
- davidtailleferMay 25, 2020Copper Contributor
Riny_van_Eekelen Ok. I've unmerged those cells. That worked out perfect. Then I adjusted the code, removing a +2 in the 5th line. It works great now.
I appreciate all of the assistance.