Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Rearrange columns using VBA


I know that i can just record a macro that moves columns around.
However, I want one that allows me to put them in a certain order based
on criteria i define. For example, my columns might sometimes come into
my spreadsheet as B,C,D,A,G,H,I,F and other times as F,B,C,A,D,E,H,I.
How can I create a macro that reorganizes them after they've come in? i
don't want them to show alphabetically, i just want them to show in the
order that I designate.

Any help would be appreciated. I am fairly new at this and am tired of
jerry-rigging things to make them appear to work.


--
ktpack
------------------------------------------------------------------------
ktpack's Profile: http://www.excelforum.com/member.php...o&userid=12167
View this thread: http://www.excelforum.com/showthread...hreadid=387640

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Rearrange columns using VBA


Do they always have the same labels at the top?


--
Losse
------------------------------------------------------------------------
Losse's Profile: http://www.excelforum.com/member.php...o&userid=24813
View this thread: http://www.excelforum.com/showthread...hreadid=387640

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Rearrange columns using VBA


Yes. Do you have an idea

--
ktpac
-----------------------------------------------------------------------
ktpack's Profile: http://www.excelforum.com/member.php...fo&userid=1216
View this thread: http://www.excelforum.com/showthread.php?threadid=38764

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Rearrange columns using VBA


Sure. If column A is supposed to be "Aaa" do:

Range("A1").Select
Do Until ActiveCell.Value = Aaa
ActiveCell.Offset(0, 1).Select
Loop
Selection.Name = Start
Do While ActiveCell < ""
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell.Offset(-1, 0).Select
Selection.Name = End
Do While ActiveCell < ""
ActiveCell.Offset(0, -1).Select
Loop
Selection.Name = End2
Range("A1").Select
Selection.EntireColumn.Insert
Range("Start:End").Select
Selection.Copy
Range("A1:End2").Select
ActiveSheet.Paste


Just be sure to change the names for each of them. I'm sure there ar
much easier ways to do this, but this is the only way that comes t
mind

--
Loss
-----------------------------------------------------------------------
Losse's Profile: http://www.excelforum.com/member.php...fo&userid=2481
View this thread: http://www.excelforum.com/showthread.php?threadid=38764

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Rearrange columns using VBA


I get a syntax error with this line:

Selection.Name = End


--
ktpack
------------------------------------------------------------------------
ktpack's Profile: http://www.excelforum.com/member.php...o&userid=12167
View this thread: http://www.excelforum.com/showthread...hreadid=387640



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Rearrange columns using VBA


Selection.Name = "End"

The same needs to be done for the others. Sorry. :-P


--
Losse
------------------------------------------------------------------------
Losse's Profile: http://www.excelforum.com/member.php...o&userid=24813
View this thread: http://www.excelforum.com/showthread...hreadid=387640

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Rearrange columns using VBA


oh. duh. i feel dumb for not figuring that one out myself. thanks

--
ktpac
-----------------------------------------------------------------------
ktpack's Profile: http://www.excelforum.com/member.php...fo&userid=1216
View this thread: http://www.excelforum.com/showthread.php?threadid=38764

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Rearrange columns using VBA


Anyone have any easier ways to do this? I need to rearange about 30-40
columns and insert blank ones at specific points based on the column
header name. Any ideas?


--
drdavidge
------------------------------------------------------------------------
drdavidge's Profile: http://www.excelforum.com/member.php...o&userid=36168
View this thread: http://www.excelforum.com/showthread...hreadid=387640

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
rearrange the data in columns by dates? Frank Excel Discussion (Misc queries) 1 March 25th 10 09:41 PM
Rearrange data in columns Alvarez Excel Discussion (Misc queries) 4 October 7th 08 08:32 AM
Rearrange data into other columns JLatham Excel Discussion (Misc queries) 6 August 17th 08 01:45 AM
Reoreder/Rearrange columns through Macros Chandrasekaran P[_2_] Excel Discussion (Misc queries) 5 May 10th 07 11:14 PM
Rearrange two columns of data RexAtHighSpeed Excel Discussion (Misc queries) 1 December 20th 05 08:26 PM


All times are GMT +1. The time now is 11:21 PM.

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

About Us

"It's about Microsoft Excel"