Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dow Dow is offline
external usenet poster
 
Posts: 31
Default Missing Headers


I have a list of 35 words and phrases that may appear as headers in my
spreadsheet. They do not always appear though.

I would like to write a script that will find the ones missing and add
them.

I found this, but it only works one at a time:

Dim XLCell As Range

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

I thought of using an Array to help but I have not had any luck with
the script.

Does anyone out there have some suggestions?

Thank you again for all the help,

Dow. MH
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Missing Headers

if you have your full list in a table - maybe on another sheet, you can use
MATCH in the next column to check if they're in the header row
....thats just sheet functions
so your code just needs to check this

suppose those 35 checks are in a range named 'checks' on sheet2 and your
headers are in row 1 of sheet1

your formula would be =MATCH(A1,Sheet1!1:1,false)

this will be a number for headers that match or #N/A if they're missing

then run this sub...
Sub FillMissing()
Dim cell As Range
Dim target As Range
For Each cell In Worksheets("sheet2").Range("Checks").Cells
If IsError(cell.Value) Then
Worksheets("Sheet1").Range("IV1").End(xlToLeft).Of fset(, 1)
= cell.Offset(, -1).Value
End If
Next
End Sub




"Dow" wrote in message
...

I have a list of 35 words and phrases that may appear as headers in my
spreadsheet. They do not always appear though.

I would like to write a script that will find the ones missing and add
them.

I found this, but it only works one at a time:

Dim XLCell As Range

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

I thought of using an Array to help but I have not had any luck with
the script.

Does anyone out there have some suggestions?

Thank you again for all the help,

Dow. MH


  #3   Report Post  
Posted to microsoft.public.excel.programming
Dow Dow is offline
external usenet poster
 
Posts: 31
Default Missing Headers

On May 20, 9:05*am, "Patrick Molloy"
wrote:
if you have your full list in a table - maybe on another sheet, you can use
MATCH in the next column to check if they're in the header row
...thats just sheet functions
so your code just needs to check this

suppose those 35 checks are in a range named 'checks' on sheet2 and your
headers are in row 1 of sheet1

your formula would be =MATCH(A1,Sheet1!1:1,false)

this will be a number for headers that match or #N/A if they're missing

then run this sub...
Sub FillMissing()
* * Dim cell As Range
* * Dim target As Range
* * * * For Each cell In Worksheets("sheet2").Range("Checks").Cells
* * * * * * If IsError(cell.Value) Then
* * * * * * * * Worksheets("Sheet1").Range("IV1").End(xlToLeft).Of fset(, 1)
= cell.Offset(, -1).Value
* * * * * * End If
* * * * *Next
End Sub

"Dow" wrote in message

...





I have a list of 35 words and phrases that may appear as headers in my
spreadsheet. *They do not always appear though.


I would like to write a script that will find the ones missing and add
them.


I found this, but it only works one at a time:


Dim XLCell As Range


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


I thought of using an Array to help but I have not had any luck with
the script.


Does anyone out there have some suggestions?


Thank you again for all the help,


Dow. MH- Hide quoted text -


- Show quoted text -


Patrick,

Thank you. This made perfect sense and it works like a charm.

Dow.
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
Inserting Columns based on missing headers Dow Excel Programming 4 May 20th 09 04:41 PM
lookup using column headers and row headers Memphus01 Excel Discussion (Misc queries) 1 April 13th 09 04:57 PM
Missing Column Headers / Can't scroll to top RobynW Excel Discussion (Misc queries) 2 February 26th 08 10:47 PM
Hide Column Headers but not row (Headers) Kevan Gradwell Excel Programming 1 March 16th 07 05:59 PM
Missing Column and Row Headers? griz4b Excel Discussion (Misc queries) 1 February 26th 06 06:37 AM


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