Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Pank
 
Posts: n/a
Default How to insert the contents of two cells in a footer?

I want to insert the contents of 2 cells (L5 and M5) into a footer.

I am using the following: -

ActiveSheet.PageSetup.LeftFooter = Range("M5").Value

When, I change the Range command to read Range("M5,L5").Value, I just get
the contents for cell L5 printed (which by the way is a date that has been
formatted to dd/mm/yyyy).

When, I change the Range command to read Range("M5:L5").Value, I just get
the contents for cell M5 printed (which by the way is text).

When, I change the Range command to read Range("M5", "L5").Value, I just get
the contents for cell M5 printed (which by the way is text).

I also defined cells L5 and M5 as a named range (For_Week). When, I change
the Range command to read Range("For_Week€ť).Value, I just get the contents
for cell M5 printed (which by the way is text).

I have had a look at the print preview and in the Left Footer I can see the
Text €śFOR WEEK€ť but nothing after it.

Can you please help to solve my problem?

  #2   Report Post  
paul
 
Posts: n/a
Default

this worked for me to "concatenate" two cells with a space in the middle

mystring = Range("M5").Value
mytstring2 = Range("L5").Value
myfooter = mystring & " " & mystring2
--
paul
remove nospam for email addy!



"Pank" wrote:

I want to insert the contents of 2 cells (L5 and M5) into a footer.

I am using the following: -

ActiveSheet.PageSetup.LeftFooter = Range("M5").Value

When, I change the Range command to read Range("M5,L5").Value, I just get
the contents for cell L5 printed (which by the way is a date that has been
formatted to dd/mm/yyyy).

When, I change the Range command to read Range("M5:L5").Value, I just get
the contents for cell M5 printed (which by the way is text).

When, I change the Range command to read Range("M5", "L5").Value, I just get
the contents for cell M5 printed (which by the way is text).

I also defined cells L5 and M5 as a named range (For_Week). When, I change
the Range command to read Range("For_Week€ť).Value, I just get the contents
for cell M5 printed (which by the way is text).

I have had a look at the print preview and in the Left Footer I can see the
Text €śFOR WEEK€ť but nothing after it.

Can you please help to solve my problem?

  #3   Report Post  
Pank
 
Posts: n/a
Default

Paul,

I have the following code but it only prints the date (in the format I want).

Private Sub Workbook_BeforePrint(Cancel As Boolean)
mystring = Format(Range("M5").Value, "dd/mm/yyyy")
mytstring2 = Range("L5").Value
myfooter = mystring & " " & mystring2
Me.Unprotect
ActiveSheet.PageSetup.LeftFooter = myfooter
Me.Protect
End Sub

Any more suggestions?

Pank

"paul" wrote:

this worked for me to "concatenate" two cells with a space in the middle

mystring = Range("M5").Value
mytstring2 = Range("L5").Value
myfooter = mystring & " " & mystring2
--
paul
remove nospam for email addy!



"Pank" wrote:

I want to insert the contents of 2 cells (L5 and M5) into a footer.

I am using the following: -

ActiveSheet.PageSetup.LeftFooter = Range("M5").Value

When, I change the Range command to read Range("M5,L5").Value, I just get
the contents for cell L5 printed (which by the way is a date that has been
formatted to dd/mm/yyyy).

When, I change the Range command to read Range("M5:L5").Value, I just get
the contents for cell M5 printed (which by the way is text).

When, I change the Range command to read Range("M5", "L5").Value, I just get
the contents for cell M5 printed (which by the way is text).

I also defined cells L5 and M5 as a named range (For_Week). When, I change
the Range command to read Range("For_Week€ť).Value, I just get the contents
for cell M5 printed (which by the way is text).

I have had a look at the print preview and in the Left Footer I can see the
Text €śFOR WEEK€ť but nothing after it.

Can you please help to solve my problem?

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

You have a couple of typos:

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim myString As String
Dim myString2 As String
Dim myFooter As String

myString = Format(Range("M5").Value, "dd/mm/yyyy")
myString2 = Range("L5").Value
myFooter = myString & " " & myString2
Me.Unprotect
ActiveSheet.PageSetup.LeftFooter = myFooter
Me.Protect
End Sub

Sometimes you used mytstring2 and sometimes you used mystring2. If you force
yourself to declare your variables ("Option Explicit" at the top of the module),
these errors can be found much more quickly.

And I don't think you need to unprotect the sheet to change the footer--which is
a problem when you really want that footer protected!

Pank wrote:

Paul,

I have the following code but it only prints the date (in the format I want).

Private Sub Workbook_BeforePrint(Cancel As Boolean)
mystring = Format(Range("M5").Value, "dd/mm/yyyy")
mytstring2 = Range("L5").Value
myfooter = mystring & " " & mystring2
Me.Unprotect
ActiveSheet.PageSetup.LeftFooter = myfooter
Me.Protect
End Sub

Any more suggestions?

Pank

"paul" wrote:

this worked for me to "concatenate" two cells with a space in the middle

mystring = Range("M5").Value
mytstring2 = Range("L5").Value
myfooter = mystring & " " & mystring2
--
paul
remove nospam for email addy!



"Pank" wrote:

I want to insert the contents of 2 cells (L5 and M5) into a footer.

I am using the following: -

ActiveSheet.PageSetup.LeftFooter = Range("M5").Value

When, I change the Range command to read Range("M5,L5").Value, I just get
the contents for cell L5 printed (which by the way is a date that has been
formatted to dd/mm/yyyy).

When, I change the Range command to read Range("M5:L5").Value, I just get
the contents for cell M5 printed (which by the way is text).

When, I change the Range command to read Range("M5", "L5").Value, I just get
the contents for cell M5 printed (which by the way is text).

I also defined cells L5 and M5 as a named range (For_Week). When, I change
the Range command to read Range("For_Week€ť).Value, I just get the contents
for cell M5 printed (which by the way is text).

I have had a look at the print preview and in the Left Footer I can see the
Text €śFOR WEEK€ť but nothing after it.

Can you please help to solve my problem?


--

Dave Peterson
  #5   Report Post  
Pank
 
Posts: n/a
Default

Dave,

Once again Super Dave to the rescue, but seriously many thanks.

My thanks to Paul as well.

Regards

Pank

"Dave Peterson" wrote:

You have a couple of typos:

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim myString As String
Dim myString2 As String
Dim myFooter As String

myString = Format(Range("M5").Value, "dd/mm/yyyy")
myString2 = Range("L5").Value
myFooter = myString & " " & myString2
Me.Unprotect
ActiveSheet.PageSetup.LeftFooter = myFooter
Me.Protect
End Sub

Sometimes you used mytstring2 and sometimes you used mystring2. If you force
yourself to declare your variables ("Option Explicit" at the top of the module),
these errors can be found much more quickly.

And I don't think you need to unprotect the sheet to change the footer--which is
a problem when you really want that footer protected!

Pank wrote:

Paul,

I have the following code but it only prints the date (in the format I want).

Private Sub Workbook_BeforePrint(Cancel As Boolean)
mystring = Format(Range("M5").Value, "dd/mm/yyyy")
mytstring2 = Range("L5").Value
myfooter = mystring & " " & mystring2
Me.Unprotect
ActiveSheet.PageSetup.LeftFooter = myfooter
Me.Protect
End Sub

Any more suggestions?

Pank

"paul" wrote:

this worked for me to "concatenate" two cells with a space in the middle

mystring = Range("M5").Value
mytstring2 = Range("L5").Value
myfooter = mystring & " " & mystring2
--
paul
remove nospam for email addy!



"Pank" wrote:

I want to insert the contents of 2 cells (L5 and M5) into a footer.

I am using the following: -

ActiveSheet.PageSetup.LeftFooter = Range("M5").Value

When, I change the Range command to read Range("M5,L5").Value, I just get
the contents for cell L5 printed (which by the way is a date that has been
formatted to dd/mm/yyyy).

When, I change the Range command to read Range("M5:L5").Value, I just get
the contents for cell M5 printed (which by the way is text).

When, I change the Range command to read Range("M5", "L5").Value, I just get
the contents for cell M5 printed (which by the way is text).

I also defined cells L5 and M5 as a named range (For_Week). When, I change
the Range command to read Range("For_Week€).Value, I just get the contents
for cell M5 printed (which by the way is text).

I have had a look at the print preview and in the Left Footer I can see the
Text €œFOR WEEK€ but nothing after it.

Can you please help to solve my problem?


--

Dave Peterson

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 do I insert a symbol BEFORE text for multiple cells in Excel? amspalinger Excel Worksheet Functions 6 May 17th 05 07:26 PM
Help me! There is problem with cells view... :-) Excel Discussion (Misc queries) 1 April 28th 05 01:16 PM
copy group of cells to another group of cells using "IF" in third Chuckak Excel Worksheet Functions 2 November 10th 04 06:04 PM
Modify Row & Cell Contents based upon Cells Values bpat1434 Excel Worksheet Functions 0 November 7th 04 03:31 PM
Modify Row & Cell Contents based upon Cells Values bpat1434 Excel Worksheet Functions 1 November 7th 04 12:43 PM


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