+ Reply to Thread
Results 1 to 10 of 10

VBA to Set the font name, size and alignment

  1. #1
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    VBA to Set the font name, size and alignment

    Hello All,

    I would like to know if this string can be modified to include Font name, size and alignment?

    Please Login or Register  to view this content.
    Any thoughts?

    Regards,

    John
    Last edited by JJFletcher; 12-23-2021 at 09:42 AM.

  2. #2
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,743

    Re: VBA to Set the font name, size and alignment

    This should work:


    Please Login or Register  to view this content.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2402-17328.20068
    Posts
    1,361

    Re: VBA to Set the font name, size and alignment

    I created this based on the fact that you look to be changing the formatting of a workbook where the code does not reside, much the same as KOKO's code above:

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: VBA to Set the font name, size and alignment

    I thank you both KOKOSEK and CheeseSandwich,

    Your contribution has had success, Mr Sandwich your solution has produced the desired results... Thanks so much

    Regards,

    John
    Last edited by JJFletcher; 12-23-2021 at 09:43 AM. Reason: spelling

  5. #5
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: VBA to Set the font name, size and alignment

    Hello Again,

    I have an interesting question....

    Because this code worked so well, can it also be used to clear the data in the destination Workbook / Worksheet?

    Please Login or Register  to view this content.
    Your thoughts,

    Regards,

    John

  6. #6
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2402-17328.20068
    Posts
    1,361

    Re: VBA to Set the font name, size and alignment

    Yes, you was nearly there:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: VBA to Set the font name, size and alignment

    Thanks Mr Sandwich,

    This cleared the data but indicated an error stating Object Required

    Please Login or Register  to view this content.
    Trying yours now Mr Sandwich

    Regards,

    John

  8. #8
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: VBA to Set the font name, size and alignment

    Mr Sandwich,

    Yours worked perfect - Thanks so much

    Regards,

    John

  9. #9
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2402-17328.20068
    Posts
    1,361

    Re: VBA to Set the font name, size and alignment

    The best way to look at this is:


    wbDest is defined as workbook only (no sheets no ranges)

    wsDest is defined as wbDest.Sheets("WorksheetName") - Notice how we have refrenced wbDest, this is now included in wsDest. (again no ranges)

    You can now refer to the new workbook by wsDest.Range("A1") as the workbook and worksheet are contained within wsDest


    Sorry if my description isnt great, i am not the best at explaining things

    Hope this helps

  10. #10
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: VBA to Set the font name, size and alignment

    Mr Sandwich,

    Thanks so much...

    Regards,

    John

+ 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. Replies: 1
    Last Post: 07-31-2021, 03:23 PM
  2. Refer .font.name, .font.size, line.dashstyle to a cell instead of hard coding.
    By avarshav in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-17-2016, 11:50 AM
  3. Replies: 15
    Last Post: 05-31-2012, 10:34 AM
  4. Replies: 3
    Last Post: 07-06-2011, 01:30 PM
  5. Replies: 5
    Last Post: 04-22-2011, 10:21 AM
  6. Tab/space alignment/organization with Arial font
    By Paloopi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-16-2006, 03:20 AM
  7. Dropdown list for font size, font type and number formats
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-09-2005, 01:06 PM

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