LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Inserting Columns based on missing headers

see my earlier response to your later question

regards

"Dow" wrote in message
...
I have a spreadsheet with columns labeled, for example, X1 X2 X3 X4 X5
X6 X7 X8 X9 X10. I need all 10 columns but where this data pulls from
only gives me the columns that have data in the rows below. So if
column X2 is blank it does not pull X2 and would give me X1 X3 X4 X5
X6 X7 X8 X9 X10.

I found this macro for when there is only 1 column missing:

Dim XLCell As Range

Set XLCell = Sheets("Test").Range("1:1").Find("X4", , xlValues,
xlWhole)
If XLCell Is Nothing Then Sheets("Test").Range
("B1").EntireColumn.Insert
Sheets("Test").Range("B1").Value = "X4"

I can run this 10 times as 10 seperate Subs changing X4 to X1 and then
X2 and etc. to make sure I have all of my columns.

I suspect there is a better way to do this. Does anyone know a macro
that will check row 1 for all of these values and then insert the
missing ones? The location that it inserts them in is not important
(it could even add them onto the end) because I will be sorting them
afterwards.

Thank you for the help,

Dow.




 
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
Inserting Columns Based on List SixBowls Excel Discussion (Misc queries) 0 August 26th 09 03:42 PM
Missing Column Headers / Can't scroll to top RobynW Excel Discussion (Misc queries) 2 February 26th 08 10:47 PM
Inserting text into custom headers / footers SyracusePete Excel Discussion (Misc queries) 3 March 22nd 07 03:38 PM
Missing Column and Row Headers? griz4b Excel Discussion (Misc queries) 1 February 26th 06 06:37 AM
Inserting column headers Steve Excel Programming 3 September 30th 04 04:02 PM


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