Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
rearrange the data in columns by dates? | Excel Discussion (Misc queries) | |||
Rearrange data in columns | Excel Discussion (Misc queries) | |||
Rearrange data into other columns | Excel Discussion (Misc queries) | |||
Reoreder/Rearrange columns through Macros | Excel Discussion (Misc queries) | |||
Rearrange two columns of data | Excel Discussion (Misc queries) |