+ Reply to Thread
Results 1 to 10 of 10

Macro button to insert cell contents in header

  1. #1
    Registered User
    Join Date
    03-08-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    5

    Macro button to insert cell contents in header

    I'm trying to figure out a way to insert cell contents into a header automatically. I put together quotes for several people, and id like to be able to "click" a button and have the correct information populate the header. It will only be on one sheet so I am using the right click on sheet>view code method.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro button to insert cell contents in header

    Need more specifics. ie. What do you want to go where?

    A copy of your workbook or screenshots with before and after examples always helps

  3. #3
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Macro button to insert cell contents in header

    Hi,

    It would be better if you could post a sample file for others to understand your requirements and advise accordingly.
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  4. #4
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Macro button to insert cell contents in header

    @stnkynts ,

    Sorry my page was not refreshed with your post.

  5. #5
    Registered User
    Join Date
    03-08-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Macro button to insert cell contents in header

    I can't post the file per regs, but I have a multiple sheets in a file that I use to quote projects. I can put the information in any cell and remove it from the print field, but I want a button with each person's name on it. When I click the button, I need the right header to populate with their info. I have salesman all over the country, so I'm tired of changing the name, address, phone number, and email each time I put a quote together.

  6. #6
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Macro button to insert cell contents in header

    Hi,

    Use this code below.


    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-08-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Macro button to insert cell contents in header

    That works. My current code looks like this, to populate the Right header only:

    Private Sub RoundedRectangle4_Click()
    'Header for salesman X
    With ActiveSheet.PageSetup
    .RightHeader = "Account Manager - XXXXX Division"
    End With
    End Sub


    Is there a way to format the text so I can add multiple lines under this one? I need name, then on the next line I need division, then street, then city/state/zip, then phone numbers, etc. I'll need 7 lines total.

  8. #8
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Macro button to insert cell contents in header

    @dahouse,

    Use this code. Separate the fields with Chr(10) , which is basically equivalent to new line.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    03-08-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Macro button to insert cell contents in header

    That works exactly as advertised. Is there a way to set the font size in the code as well?

  10. #10
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Macro button to insert cell contents in header

    Hi,

    Try this code.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1