Share via

VBA Footer Problem

Anonymous
2021-11-01T14:01:27+00:00

When i try to set the right and left footer using the same method the code fails.

Sub FootL()

Const FontSize = 12

ActiveSheet.PageSetup.LeftFooter = "&" & FontSize & Range("UKaddress1").Value

ActiveSheet.PageSetup.RightFooter = "&" & FontSize & Range("UKaddress2").Value

End Sub

error code: unable to set the rightfooter property of the pagesetup class

The left footer populates correctly but fails on the right footer

Any help much appreciated

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

5 answers

Sort by: Most helpful
  1. HansV 462.6K Reputation points
    2021-11-02T08:24:05+00:00

    You can't - 255 characters is a hard limit. As an alternative, you could place the addresses at the top of the sheet and repeat the top row(s).

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2021-11-01T22:22:45+00:00

    I believe the two addresses have a character count greater than 255 which is causing the issue. Do you know how i can increase the character count?

    Was this answer helpful?

    0 comments No comments
  3. HansV 462.6K Reputation points
    2021-11-01T15:15:29+00:00

    I created a small sample workbook and named two cells UKaddress1 and UKaddress2.

    I tested the code with different values in UKaddress1 and UKaddress2. It ran as intended without error...

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2021-11-01T14:58:16+00:00

    UKaddress2 is just a defined cell that contains a normal address. It is the same format as UKaddress1, the code will work if I run them individual but fails when i put them in the same code.

    Was this answer helpful?

    0 comments No comments
  5. HansV 462.6K Reputation points
    2021-11-01T14:41:22+00:00

    There might be something in the value of UKaddress2 that confuses Excel, for example because it looks like a format code for the footer.

    What is the value of UKaddress2?

    Was this answer helpful?

    0 comments No comments