Find/move column by header

doriannjeshi

Active Member
Joined
Apr 5, 2015
Messages
338
Office Version
  1. 365
Platform
  1. Windows
Hi,
I need to find a column with header named "example" and move this column to a specified column nr
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Code:
Sub Maybe()
Columns(Rows(1).Find("example").Column).Cut
Columns(10).Insert Shift:=xlToRight
End Sub
 
Upvote 0
One more thing, can this be done to find the column closest to a1, as it is it starts from right to left and it's returning the wrong column since I have to columns named the same by default, I need the opposite.
 
Upvote 0
Code:
Columns(Rows(1).Find("example", Cells(1, 1)).Column).Cut
Did you check that all the cells that have "example" do not have leading or trailing characters (maybe spaces)?
 
Upvote 0

Forum statistics

Threads
1,225,734
Messages
6,186,714
Members
453,369
Latest member
positivemind

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