ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Column Cut/Paste possible? (https://www.excelbanter.com/excel-programming/392012-column-cut-paste-possible.html)

Kigol

Column Cut/Paste possible?
 
1) When I use insert twice, it can create a large number of blank
columns between the sorted data and the raw data, much more than
expected for some reason. I do not want this.

2) If I cut/paste into a blank column, it errors. Apparently you
cannot paste columns?


For x = 1 To 18
Columns(x).Insert

Set testrng = Cells.Find(What:=Me.Controls("ComboBox" &
x).Value, After:=ActiveCell, LookAt:=xlWhole, SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:=False)

If Not testrng Is Nothing Then
testrng.EntireColumn.Cut
Columns(x).Insert '(Ideally I would like to
PasteSpecial to eliminate all the excessive column creation.)
End If
Next x

Any insight is appreciated.


Kigol

Column Cut/Paste possible?
 
On Jun 25, 1:58 pm, Kigol wrote:
1) When I use insert twice, it can create a large number of blank
columns between the sorted data and the raw data, much more than
expected for some reason. I do not want this.

2) If I cut/paste into a blank column, it errors. Apparently you
cannot paste columns?

For x = 1 To 18
Columns(x).Insert

Set testrng = Cells.Find(What:=Me.Controls("ComboBox" &
x).Value, After:=ActiveCell, LookAt:=xlWhole, SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:=False)

If Not testrng Is Nothing Then
testrng.EntireColumn.Cut
Columns(x).Insert '(Ideally I would like to
PasteSpecial to eliminate all the excessive column creation.)
End If
Next x

Any insight is appreciated.


On a side note does instering columns create non-blank cells? Because
after running the above code and being left with empty columns, if I
run it again blank values are pulled into my array. I have tried all
methods of blank cell testing you can suggest so there must be another
cause.




All times are GMT +1. The time now is 04:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com