+ Reply to Thread
Results 1 to 7 of 7

how to apply .ShrinkToFit = True in this situation?

  1. #1
    Registered User
    Join Date
    03-26-2013
    Location
    Canada
    MS-Off Ver
    ms365
    Posts
    79

    how to apply .ShrinkToFit = True in this situation?

    hi there,

    i need to apply .ShrinkToFit = True method to the following code I have

    Please Login or Register  to view this content.
    I want the contents of cell .Cells(4, 3) to be autofit. so the size of the cell remains the same but the font size of the content inside the cell can shrink. how can I achieve this? Any helpwould be appreciated. thank you in advance.

    best regards,


    Ahsan K
    Last edited by snkhan; 09-27-2020 at 05:02 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,091

    Re: how to apply .ShrinkToFit = True in this situation?

    https://docs.microsoft.com/en-us/off...ge.shrinktofit


    So,
    Please Login or Register  to view this content.

    Is that not working for you?
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    03-26-2013
    Location
    Canada
    MS-Off Ver
    ms365
    Posts
    79

    Re: how to apply .ShrinkToFit = True in this situation?

    I don't know how to apply .Cells(4, 3).ShrinkToFit = True to the code I mentioned.

    I have tried

    Please Login or Register  to view this content.
    but I get an error, 'unable to set ShrinkToFit property'

    any suggestions?

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,091

    Re: how to apply .ShrinkToFit = True in this situation?

    Post the workbook. I don't have the sheet, the form, the data, or anything else to test this.

    This works for me:

    Please Login or Register  to view this content.
    Last edited by TMS; 09-27-2020 at 08:10 AM.

  5. #5
    Registered User
    Join Date
    03-26-2013
    Location
    Canada
    MS-Off Ver
    ms365
    Posts
    79

    Re: how to apply .ShrinkToFit = True in this situation?

    Ok, so I figured out the problem. The sheet I am trying to modify using VBA is protected. when I unprotect it, it works. How can I work around it?
    can I use ActiveSheet.Protect AllowFormattingCells:=True method somehow?
    Last edited by snkhan; 09-27-2020 at 04:19 PM.

  6. #6
    Registered User
    Join Date
    03-26-2013
    Location
    Canada
    MS-Off Ver
    ms365
    Posts
    79

    Re: how to apply .ShrinkToFit = True in this situation?

    hello,

    I figured it out

    Please Login or Register  to view this content.
    this works. Thank you so much for the help. Much appreciated

    cheers

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,091

    Re: how to apply .ShrinkToFit = True in this situation?

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help with an if/then situation
    By Lamont15 in forum Excel General
    Replies: 3
    Last Post: 07-15-2018, 04:59 PM
  2. [SOLVED] Best way to apply (multiple) VLOOKUPs via VBA to this situation ?
    By millerjj22 in forum Excel Programming / VBA / Macros
    Replies: 31
    Last Post: 05-23-2017, 03:24 AM
  3. If returns True for one apply to all subsequent and previous entities
    By Doy- in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-03-2016, 11:37 AM
  4. Apply Pivot Table Maual Update =True
    By meus in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-24-2015, 01:11 AM
  5. apply existing List, if formula is true, otherwise write text data in cell
    By Lynn Porter in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-07-2013, 08:03 PM
  6. [SOLVED] Need to apply individual True/False Value, to Multi-Cell Ratio Count Formula
    By James_D in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-04-2013, 03:55 PM
  7. #N/A situation
    By bnwash in forum Excel General
    Replies: 5
    Last Post: 07-18-2007, 04:03 AM

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