PC Review


Reply
Thread Tools Rate Thread

Copy Column data to Page Header

 
 
DavidH56
Guest
Posts: n/a
 
      13th Aug 2008
Hi,
I would like assistance to write a macro which creates a page center to read
from column data. I would like for example the text string to read "Wasuto
updates for Supervisor ?? data date ??. Wasuto would be placed if column 4
has "WAS" in the 12 character text (example:45WAS51302U35) or if "KEM" is
there instead I'd like the word "Kematsa" instead. Also I'd like the
Supervisor's name if column 5 lists his name greater than 50% of the time.
There could be up to 25 different Supervisors names. Lastly I'd like the
current date behind the word date in the string. I'm using excel 2003. There
could be up to 5000 rows of data. The firts row is the header row.
Any help would be greatly appreciated.
--
By persisting in your path, though you forfeit the little, you gain the
great.

 
Reply With Quote
 
 
 
 
Barb Reinhardt
Guest
Posts: n/a
 
      14th Aug 2008
Take a look here to find out how to use the Workbook_BeforePrint event.

http://www.mvps.org/dmcritchie/excel/pathname.htm
--
HTH,
Barb Reinhardt



"DavidH56" wrote:

> Hi,
> I would like assistance to write a macro which creates a page center to read
> from column data. I would like for example the text string to read "Wasuto
> updates for Supervisor ?? data date ??. Wasuto would be placed if column 4
> has "WAS" in the 12 character text (example:45WAS51302U35) or if "KEM" is
> there instead I'd like the word "Kematsa" instead. Also I'd like the
> Supervisor's name if column 5 lists his name greater than 50% of the time.
> There could be up to 25 different Supervisors names. Lastly I'd like the
> current date behind the word date in the string. I'm using excel 2003. There
> could be up to 5000 rows of data. The firts row is the header row.
> Any help would be greatly appreciated.
> --
> By persisting in your path, though you forfeit the little, you gain the
> great.
>

 
Reply With Quote
 
DavidH56
Guest
Posts: n/a
 
      14th Aug 2008
Thanks for your response Barb

There is a lot of good info I get here. I can see how to add the file path
and insert the date in my page header. I still would like to know which code
to use, maybe select case to insert the first word "Wasuto" in the page
center header if column 4 has "WAS" in it. Also pulling Supervisor's names
from column 5 to insert in page header also. Thanks again for your help.
--
By persisting in your path, though you forfeit the little, you gain the
great.



"Barb Reinhardt" wrote:

> Take a look here to find out how to use the Workbook_BeforePrint event.
>
> http://www.mvps.org/dmcritchie/excel/pathname.htm
> --
> HTH,
> Barb Reinhardt
>
>
>
> "DavidH56" wrote:
>
> > Hi,
> > I would like assistance to write a macro which creates a page center to read
> > from column data. I would like for example the text string to read "Wasuto
> > updates for Supervisor ?? data date ??. Wasuto would be placed if column 4
> > has "WAS" in the 12 character text (example:45WAS51302U35) or if "KEM" is
> > there instead I'd like the word "Kematsa" instead. Also I'd like the
> > Supervisor's name if column 5 lists his name greater than 50% of the time.
> > There could be up to 25 different Supervisors names. Lastly I'd like the
> > current date behind the word date in the string. I'm using excel 2003. There
> > could be up to 5000 rows of data. The firts row is the header row.
> > Any help would be greatly appreciated.
> > --
> > By persisting in your path, though you forfeit the little, you gain the
> > great.
> >

 
Reply With Quote
 
DavidH56
Guest
Posts: n/a
 
      14th Aug 2008
Thanks Barb,

This is what I have so far:

Sub FixUpdateHeader()
Dim Sentences
Dim i As Long
Dim iWordPos As Integer

Sentences = Range("D1", Range("D65536").End(xlUp))
lRow = 0
For i = Range("D65536").End(xlUp).Row To 1 Step -1
iWordPos = InStr(LCase(Sentences(i, 1)), LCase("WAS"))
If iWordPos > 0 Then
With ActiveSheet
.PageSetup.CenterHeader = "Wasuto Updates"
End With
End If
Next i
For i = Range("D65536").End(xlUp).Row To 1 Step -1
iWordPos = InStr(LCase(Sentences(i, 1)), LCase("KRS"))
If iWordPos > 0 Then
With ActiveSheet
.PageSetup.CenterHeader = "Kematsa Updates"
End With
End If
Next i
End Sub


--
By persisting in your path, though you forfeit the little, you gain the
great.



"Barb Reinhardt" wrote:

> Take a look here to find out how to use the Workbook_BeforePrint event.
>
> http://www.mvps.org/dmcritchie/excel/pathname.htm
> --
> HTH,
> Barb Reinhardt
>
>
>
> "DavidH56" wrote:
>
> > Hi,
> > I would like assistance to write a macro which creates a page center to read
> > from column data. I would like for example the text string to read "Wasuto
> > updates for Supervisor ?? data date ??. Wasuto would be placed if column 4
> > has "WAS" in the 12 character text (example:45WAS51302U35) or if "KEM" is
> > there instead I'd like the word "Kematsa" instead. Also I'd like the
> > Supervisor's name if column 5 lists his name greater than 50% of the time.
> > There could be up to 25 different Supervisors names. Lastly I'd like the
> > current date behind the word date in the string. I'm using excel 2003. There
> > could be up to 5000 rows of data. The firts row is the header row.
> > Any help would be greatly appreciated.
> > --
> > By persisting in your path, though you forfeit the little, you gain the
> > great.
> >

 
Reply With Quote
 
Barb Reinhardt
Guest
Posts: n/a
 
      14th Aug 2008
I think I'd replace some of the For i = ... next i with this

Call DefineHeader("KRS","Kematsa Updates")

Sub DefineHeader(myAcronym as string, myUpdates as string)
For i = Range("D65536").End(xlUp).Row To 1 Step -1
iWordPos = InStr(LCase(Sentences(i, 1)), LCase(myacronym))
If iWordPos > 0 Then
With ActiveSheet
.PageSetup.CenterHeader = myupdates
End With
End If
Next i
end sub

--
HTH,
Barb Reinhardt



"DavidH56" wrote:

> Thanks Barb,
>
> This is what I have so far:
>
> Sub FixUpdateHeader()
> Dim Sentences
> Dim i As Long
> Dim iWordPos As Integer
>
> Sentences = Range("D1", Range("D65536").End(xlUp))
> lRow = 0
> For i = Range("D65536").End(xlUp).Row To 1 Step -1
> iWordPos = InStr(LCase(Sentences(i, 1)), LCase("WAS"))
> If iWordPos > 0 Then
> With ActiveSheet
> .PageSetup.CenterHeader = "Wasuto Updates"
> End With
> End If
> Next i
> For i = Range("D65536").End(xlUp).Row To 1 Step -1
> iWordPos = InStr(LCase(Sentences(i, 1)), LCase("KRS"))
> If iWordPos > 0 Then
> With ActiveSheet
> .PageSetup.CenterHeader = "Kematsa Updates"
> End With
> End If
> Next i
> End Sub
>
>
> --
> By persisting in your path, though you forfeit the little, you gain the
> great.
>
>
>
> "Barb Reinhardt" wrote:
>
> > Take a look here to find out how to use the Workbook_BeforePrint event.
> >
> > http://www.mvps.org/dmcritchie/excel/pathname.htm
> > --
> > HTH,
> > Barb Reinhardt
> >
> >
> >
> > "DavidH56" wrote:
> >
> > > Hi,
> > > I would like assistance to write a macro which creates a page center to read
> > > from column data. I would like for example the text string to read "Wasuto
> > > updates for Supervisor ?? data date ??. Wasuto would be placed if column 4
> > > has "WAS" in the 12 character text (example:45WAS51302U35) or if "KEM" is
> > > there instead I'd like the word "Kematsa" instead. Also I'd like the
> > > Supervisor's name if column 5 lists his name greater than 50% of the time.
> > > There could be up to 25 different Supervisors names. Lastly I'd like the
> > > current date behind the word date in the string. I'm using excel 2003. There
> > > could be up to 5000 rows of data. The firts row is the header row.
> > > Any help would be greatly appreciated.
> > > --
> > > By persisting in your path, though you forfeit the little, you gain the
> > > great.
> > >

 
Reply With Quote
 
DavidH56
Guest
Posts: n/a
 
      14th Aug 2008
Barb,
I get a type mismatch on this line of code.
iWordPos = InStr(LCase(Sentences(i, 1)), LCase(myAcronym))

Thanks
--
By persisting in your path, though you forfeit the little, you gain the
great.



"Barb Reinhardt" wrote:

> I think I'd replace some of the For i = ... next i with this
>
> Call DefineHeader("KRS","Kematsa Updates")
>
> Sub DefineHeader(myAcronym as string, myUpdates as string)
> For i = Range("D65536").End(xlUp).Row To 1 Step -1
> iWordPos = InStr(LCase(Sentences(i, 1)), LCase(myacronym))
> If iWordPos > 0 Then
> With ActiveSheet
> .PageSetup.CenterHeader = myupdates
> End With
> End If
> Next i
> end sub
>
> --
> HTH,
> Barb Reinhardt
>
>
>
> "DavidH56" wrote:
>
> > Thanks Barb,
> >
> > This is what I have so far:
> >
> > Sub FixUpdateHeader()
> > Dim Sentences
> > Dim i As Long
> > Dim iWordPos As Integer
> >
> > Sentences = Range("D1", Range("D65536").End(xlUp))
> > lRow = 0
> > For i = Range("D65536").End(xlUp).Row To 1 Step -1
> > iWordPos = InStr(LCase(Sentences(i, 1)), LCase("WAS"))
> > If iWordPos > 0 Then
> > With ActiveSheet
> > .PageSetup.CenterHeader = "Wasuto Updates"
> > End With
> > End If
> > Next i
> > For i = Range("D65536").End(xlUp).Row To 1 Step -1
> > iWordPos = InStr(LCase(Sentences(i, 1)), LCase("KRS"))
> > If iWordPos > 0 Then
> > With ActiveSheet
> > .PageSetup.CenterHeader = "Kematsa Updates"
> > End With
> > End If
> > Next i
> > End Sub
> >
> >
> > --
> > By persisting in your path, though you forfeit the little, you gain the
> > great.
> >
> >
> >
> > "Barb Reinhardt" wrote:
> >
> > > Take a look here to find out how to use the Workbook_BeforePrint event.
> > >
> > > http://www.mvps.org/dmcritchie/excel/pathname.htm
> > > --
> > > HTH,
> > > Barb Reinhardt
> > >
> > >
> > >
> > > "DavidH56" wrote:
> > >
> > > > Hi,
> > > > I would like assistance to write a macro which creates a page center to read
> > > > from column data. I would like for example the text string to read "Wasuto
> > > > updates for Supervisor ?? data date ??. Wasuto would be placed if column 4
> > > > has "WAS" in the 12 character text (example:45WAS51302U35) or if "KEM" is
> > > > there instead I'd like the word "Kematsa" instead. Also I'd like the
> > > > Supervisor's name if column 5 lists his name greater than 50% of the time.
> > > > There could be up to 25 different Supervisors names. Lastly I'd like the
> > > > current date behind the word date in the string. I'm using excel 2003. There
> > > > could be up to 5000 rows of data. The firts row is the header row.
> > > > Any help would be greatly appreciated.
> > > > --
> > > > By persisting in your path, though you forfeit the little, you gain the
> > > > great.
> > > >

 
Reply With Quote
 
Barb Reinhardt
Guest
Posts: n/a
 
      14th Aug 2008
It appears that I forgot to dimension Sentences and define it at the
beginning of the sub.
--
HTH,
Barb Reinhardt



"DavidH56" wrote:

> Barb,
> I get a type mismatch on this line of code.
> iWordPos = InStr(LCase(Sentences(i, 1)), LCase(myAcronym))
>
> Thanks
> --
> By persisting in your path, though you forfeit the little, you gain the
> great.
>
>
>
> "Barb Reinhardt" wrote:
>
> > I think I'd replace some of the For i = ... next i with this
> >
> > Call DefineHeader("KRS","Kematsa Updates")
> >
> > Sub DefineHeader(myAcronym as string, myUpdates as string)
> > For i = Range("D65536").End(xlUp).Row To 1 Step -1
> > iWordPos = InStr(LCase(Sentences(i, 1)), LCase(myacronym))
> > If iWordPos > 0 Then
> > With ActiveSheet
> > .PageSetup.CenterHeader = myupdates
> > End With
> > End If
> > Next i
> > end sub
> >
> > --
> > HTH,
> > Barb Reinhardt
> >
> >
> >
> > "DavidH56" wrote:
> >
> > > Thanks Barb,
> > >
> > > This is what I have so far:
> > >
> > > Sub FixUpdateHeader()
> > > Dim Sentences
> > > Dim i As Long
> > > Dim iWordPos As Integer
> > >
> > > Sentences = Range("D1", Range("D65536").End(xlUp))
> > > lRow = 0
> > > For i = Range("D65536").End(xlUp).Row To 1 Step -1
> > > iWordPos = InStr(LCase(Sentences(i, 1)), LCase("WAS"))
> > > If iWordPos > 0 Then
> > > With ActiveSheet
> > > .PageSetup.CenterHeader = "Wasuto Updates"
> > > End With
> > > End If
> > > Next i
> > > For i = Range("D65536").End(xlUp).Row To 1 Step -1
> > > iWordPos = InStr(LCase(Sentences(i, 1)), LCase("KRS"))
> > > If iWordPos > 0 Then
> > > With ActiveSheet
> > > .PageSetup.CenterHeader = "Kematsa Updates"
> > > End With
> > > End If
> > > Next i
> > > End Sub
> > >
> > >
> > > --
> > > By persisting in your path, though you forfeit the little, you gain the
> > > great.
> > >
> > >
> > >
> > > "Barb Reinhardt" wrote:
> > >
> > > > Take a look here to find out how to use the Workbook_BeforePrint event.
> > > >
> > > > http://www.mvps.org/dmcritchie/excel/pathname.htm
> > > > --
> > > > HTH,
> > > > Barb Reinhardt
> > > >
> > > >
> > > >
> > > > "DavidH56" wrote:
> > > >
> > > > > Hi,
> > > > > I would like assistance to write a macro which creates a page center to read
> > > > > from column data. I would like for example the text string to read "Wasuto
> > > > > updates for Supervisor ?? data date ??. Wasuto would be placed if column 4
> > > > > has "WAS" in the 12 character text (example:45WAS51302U35) or if "KEM" is
> > > > > there instead I'd like the word "Kematsa" instead. Also I'd like the
> > > > > Supervisor's name if column 5 lists his name greater than 50% of the time.
> > > > > There could be up to 25 different Supervisors names. Lastly I'd like the
> > > > > current date behind the word date in the string. I'm using excel 2003. There
> > > > > could be up to 5000 rows of data. The firts row is the header row.
> > > > > Any help would be greatly appreciated.
> > > > > --
> > > > > By persisting in your path, though you forfeit the little, you gain the
> > > > > great.
> > > > >

 
Reply With Quote
 
DavidH56
Guest
Posts: n/a
 
      14th Aug 2008
Thanks again Barb,

I've got it now.
--
By persisting in your path, though you forfeit the little, you gain the
great.



"Barb Reinhardt" wrote:

> It appears that I forgot to dimension Sentences and define it at the
> beginning of the sub.
> --
> HTH,
> Barb Reinhardt
>
>
>
> "DavidH56" wrote:
>
> > Barb,
> > I get a type mismatch on this line of code.
> > iWordPos = InStr(LCase(Sentences(i, 1)), LCase(myAcronym))
> >
> > Thanks
> > --
> > By persisting in your path, though you forfeit the little, you gain the
> > great.
> >
> >
> >
> > "Barb Reinhardt" wrote:
> >
> > > I think I'd replace some of the For i = ... next i with this
> > >
> > > Call DefineHeader("KRS","Kematsa Updates")
> > >
> > > Sub DefineHeader(myAcronym as string, myUpdates as string)
> > > For i = Range("D65536").End(xlUp).Row To 1 Step -1
> > > iWordPos = InStr(LCase(Sentences(i, 1)), LCase(myacronym))
> > > If iWordPos > 0 Then
> > > With ActiveSheet
> > > .PageSetup.CenterHeader = myupdates
> > > End With
> > > End If
> > > Next i
> > > end sub
> > >
> > > --
> > > HTH,
> > > Barb Reinhardt
> > >
> > >
> > >
> > > "DavidH56" wrote:
> > >
> > > > Thanks Barb,
> > > >
> > > > This is what I have so far:
> > > >
> > > > Sub FixUpdateHeader()
> > > > Dim Sentences
> > > > Dim i As Long
> > > > Dim iWordPos As Integer
> > > >
> > > > Sentences = Range("D1", Range("D65536").End(xlUp))
> > > > lRow = 0
> > > > For i = Range("D65536").End(xlUp).Row To 1 Step -1
> > > > iWordPos = InStr(LCase(Sentences(i, 1)), LCase("WAS"))
> > > > If iWordPos > 0 Then
> > > > With ActiveSheet
> > > > .PageSetup.CenterHeader = "Wasuto Updates"
> > > > End With
> > > > End If
> > > > Next i
> > > > For i = Range("D65536").End(xlUp).Row To 1 Step -1
> > > > iWordPos = InStr(LCase(Sentences(i, 1)), LCase("KRS"))
> > > > If iWordPos > 0 Then
> > > > With ActiveSheet
> > > > .PageSetup.CenterHeader = "Kematsa Updates"
> > > > End With
> > > > End If
> > > > Next i
> > > > End Sub
> > > >
> > > >
> > > > --
> > > > By persisting in your path, though you forfeit the little, you gain the
> > > > great.
> > > >
> > > >
> > > >
> > > > "Barb Reinhardt" wrote:
> > > >
> > > > > Take a look here to find out how to use the Workbook_BeforePrint event.
> > > > >
> > > > > http://www.mvps.org/dmcritchie/excel/pathname.htm
> > > > > --
> > > > > HTH,
> > > > > Barb Reinhardt
> > > > >
> > > > >
> > > > >
> > > > > "DavidH56" wrote:
> > > > >
> > > > > > Hi,
> > > > > > I would like assistance to write a macro which creates a page center to read
> > > > > > from column data. I would like for example the text string to read "Wasuto
> > > > > > updates for Supervisor ?? data date ??. Wasuto would be placed if column 4
> > > > > > has "WAS" in the 12 character text (example:45WAS51302U35) or if "KEM" is
> > > > > > there instead I'd like the word "Kematsa" instead. Also I'd like the
> > > > > > Supervisor's name if column 5 lists his name greater than 50% of the time.
> > > > > > There could be up to 25 different Supervisors names. Lastly I'd like the
> > > > > > current date behind the word date in the string. I'm using excel 2003. There
> > > > > > could be up to 5000 rows of data. The firts row is the header row.
> > > > > > Any help would be greatly appreciated.
> > > > > > --
> > > > > > By persisting in your path, though you forfeit the little, you gain the
> > > > > > great.
> > > > > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy data from other worksheet based on column header sbitaxi@gmail.com Microsoft Excel Misc 0 29th Apr 2008 08:18 PM
Search for a column based on the column header and then past data from it to another column in another workbook minkokiss Microsoft Excel Programming 2 5th Apr 2007 01:12 AM
copy column and header names from existing spreadsheet to new spre =?Utf-8?B?bGJpZXJlcg==?= Microsoft Excel New Users 2 15th Jul 2006 04:31 PM
Match Header...Copy Column mjack003 Microsoft Excel Misc 6 23rd Sep 2005 01:33 PM
How to Page header print at top of each column GL Microsoft Access Reports 2 12th Aug 2005 06:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:58 AM.