Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 468
Default Finding/Moving Columns within Macro

Per, Your code is neat, but how can one "equate" the Source columns to
your examples "Items1", "Items2", etc ?
TIA,



"Per Jessen" wrote:

Hi Jake

Try this:

Sub Find_Move()
Dim MyArr As Variant
Dim ColArr As Variant
Dim TargetCol As Long

MyArr = Array("Item1", "Item2", "Item3") ' Change to suit
ColArr = Array("A:A", "B:B", "C:C") ' Destination column

For i = LBound(MyArr) To UBound(MyArr)
TargetCol = Cells.Find(What:=MyArr(i)).Column
Columns(TargetCol).Cut Destination:=Columns(ColArr(i))
Next
End Sub

Regards,
Per

On 22 Nov., 18:22, Jake wrote:
So I need some advice/direction on how to perform this macro a little
more efficiently.
Everyday I export a report from our POS system at work into Excel. The
issue with the export is that none of the columns are in order so I
have to manually move the columns each time or create a macro to do
it. Currently I'm using the below code to find the column header and
move it to the correct location.

Dim intWarehouse

intWarehouse = Cells.Find(What:="Warehouse").Column
Columns(intWarehouse).Select
Selection.Cut Destination:=Columns("A:A")

I only have 15 columns that I need to find and then move but I would
think there has to be a more efficient way of doing this than creating
15 variables and using 3 lines of code for each column that I need to
find then move. For some reason I think I should be using an array but
after doing some research on arrays I'm even more confused on where to
start.

Is there a better way to do this? If so, can you point me in that
direction?

Thanks in advance -
Jake



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving Columns Macro miss_mas Excel Programming 3 July 25th 08 08:12 PM
Finding specific data and moving it to a new sheet LauraD Excel Programming 0 July 10th 06 11:07 AM
Need help with Macro in moving columns Brett Smith[_2_] Excel Programming 1 January 11th 06 06:48 PM
moving to relative location after finding data Frank Kabel Excel Programming 1 March 3rd 04 06:57 PM
Finding and moving hypens from end to beginning of cell Amy[_5_] Excel Programming 2 December 9th 03 01:15 PM


All times are GMT +1. The time now is 08:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"