+ Reply to Thread
Results 1 to 5 of 5

Copy cell formatting and keep hyperlink

  1. #1
    Registered User
    Join Date
    05-05-2012
    Location
    Dhaka, Bangladesh
    MS-Off Ver
    Excel 2010
    Posts
    3

    Copy cell formatting and keep hyperlink

    Hi all
    Here is the scenario:

    Cell(A1) has formatting such as font, font size, font colour etc.
    Cell(B1) has no formatting (i.e. it has default formatting), but it has a hyperlink.

    Now, I want to copy A1 formatting to B1 through code.
    So, I recorded a Macro by using Format Painter and copying the formatting of A1 to B1. This code is provided below:
    Please Login or Register  to view this content.
    However the problem is that when I copy A1 formatting to B1 through "Format Painter" (in other words the code above), not only is the formatting copied to B1, the hyperlink present in B1 (and not present in A1) is also erased.

    So, the solution I need is a way to copy the formatting of A1 to B1 only and keep the hyperlink in B1.

    Hope I have been able to explain myself :-)
    Can someone please help?

    Thanks in advance.
    Attached Files Attached Files
    Last edited by SNK111; 05-06-2012 at 12:21 AM. Reason: Added a sample XSLM file as attachment

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy cell formatting and keep hyperlink

    Click GO ADVANCED and use the paperclip icon to post up a copy of your workbook. Make sure the workbook demonstrates your desired results if possible, or just highlight the cells you're trying to fix. Use BEFORE/AFTER sheets if that helps make it clearer.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    05-05-2012
    Location
    Dhaka, Bangladesh
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Copy cell formatting and keep hyperlink

    Hi Jerry
    Thanks for your reply.

    As suggested, I have added a sample XSLM file as attachment.

  4. #4
    Registered User
    Join Date
    05-05-2012
    Location
    Dhaka, Bangladesh
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Copy cell formatting and keep hyperlink

    Hi Jerry
    Thanks for your reply.

    As suggested, I have added a sample XSLM file as attachment.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy cell formatting and keep hyperlink

    I suppose one way is to simply remember the Hyperlink and put it back. Also, always remember to remove all the "selecting", the macro recorder records your human actions, too, those need to be edited out.

    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