Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default bringing up a window to make header row selections

So here's what I'm starting with and what I'd like to do with it.

I start with a large spreadsheet with values in several columns. I
have a macro that goes through and cuts out columns by specfic column
values (A, G, L thru Q, etc.). But, since the reporting department
responsible for maintaining this file doesn't do such a great job of
maintenance, this specific cut/paste by column isn't working any
longer.

What I'd like to do is have a window pop up with two fields. On the
left is a list of all the Headers found in Row 1. You can then select
which Headers you'd like to move over into the right hand side. When
the 'OK' button is pressed, the macro is executed and the un-selected
columns on the left hand side are cleared while the selected columns
are all re-organized and placed side by side with no blank columns in
between them. Can somebody please help me out on this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default bringing up a window to make header row selections

interesting
i assume first header is in A1 and that theer are no gaps in the headers

add a userform. place two listboxes (listbox1, listbox2) and a command button

double clicking either box will move the item selected to the other box.
order isn't relevent. clicking the command button will delete columns in
listbox1 - by default, everything else moves left, then adds back the removed
headers

Option Explicit
Private Sub CommandButton1_Click()
Dim index As Long
Dim cl As Long
'delete remaing columns in listbox1
With ListBox1
For index = 0 To .ListCount - 1
For cl = 1 To Range("A1").End(xlToRight).Column
If Cells(1, cl).Value = .List(index) Then
Columns(cl).Delete
Exit For
End If
Next
Next
' add back deleted headings
For index = 0 To .ListCount - 1
Cells(ListBox2.ListCount + index + 1) = .List(index)
Next
End With
Unload Me
End Sub

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
ListBox2.AddItem ListBox1.Value
ListBox1.RemoveItem (ListBox1.ListIndex)
End Sub



Private Sub ListBox2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
ListBox1.AddItem ListBox2.Value
ListBox2.RemoveItem (ListBox2.ListIndex)
End Sub

Private Sub UserForm_Initialize()


Dim cl As Long
With ListBox1
For cl = 1 To Range("A1").End(xlToRight).Column
.AddItem Cells(1, cl)
Next
End With

End Sub










"Matthew Dyer" wrote:

So here's what I'm starting with and what I'd like to do with it.

I start with a large spreadsheet with values in several columns. I
have a macro that goes through and cuts out columns by specfic column
values (A, G, L thru Q, etc.). But, since the reporting department
responsible for maintaining this file doesn't do such a great job of
maintenance, this specific cut/paste by column isn't working any
longer.

What I'd like to do is have a window pop up with two fields. On the
left is a list of all the Headers found in Row 1. You can then select
which Headers you'd like to move over into the right hand side. When
the 'OK' button is pressed, the macro is executed and the un-selected
columns on the left hand side are cleared while the selected columns
are all re-organized and placed side by side with no blank columns in
between them. Can somebody please help me out on this?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default bringing up a window to make header row selections

This is working BEAUTIFULLY! I'll tinker with it a little bit to get
it exactly how I'd like it, but this is exactly what I needed. Haha,
it took me a few minutes to figure out how to get the userform to pop
up.

I am always suprised how much help I can find here on google groups
but when trying to ask for help in a forum that you have to subscribe
to and all that jazz nobody seems to want to offer any assistance at
all.

THANKS AGAIN!
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
How to make a selected row visible in the Window? Raj[_2_] Excel Programming 0 January 24th 08 01:36 PM
Excel 2002 - How do I use the "name" header in the watch window? Keith Excel Discussion (Misc queries) 2 May 3rd 05 07:31 AM
How can I allow users to make multiple selections from a dropdown. Liz Excel Worksheet Functions 0 February 17th 05 05:21 AM
How to Make Multiple List Box Selections Populate A Column in Excel Excel Nerd Excel Programming 1 January 23rd 04 12:46 AM
Make a window stay on top Amardeep Excel Programming 0 September 12th 03 01:33 AM


All times are GMT +1. The time now is 09:46 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"