Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I insert a symbol BEFORE text for multiple cells in Excel? | Excel Worksheet Functions | |||
Help me! There is problem with cells view... | Excel Discussion (Misc queries) | |||
copy group of cells to another group of cells using "IF" in third | Excel Worksheet Functions | |||
Modify Row & Cell Contents based upon Cells Values | Excel Worksheet Functions | |||
Modify Row & Cell Contents based upon Cells Values | Excel Worksheet Functions |