+ Reply to Thread
Results 1 to 4 of 4

How to automate VBA Columnwidth using Named Ranges fields

  1. #1
    Registered User
    Join Date
    12-08-2013
    Location
    United States
    MS-Off Ver
    Microsoft 365
    Posts
    69

    How to automate VBA Columnwidth using Named Ranges fields

    I am trying to automate changing the width of specific columns by passing data to a vba formula to avoid opening up the vba to make the changes.

    I have two Named Ranges fields, the first is called “I_data_col”, which has the column ranges like “B:B” that is identified for the width change. The second is called “I_data_width”, which has the column width like “10” that will be used to change the column width.

    I have a simple vba code to automate the process (see below), but I am getting a “Mismatch Error (Run-time error 13)”. How do I fix the mismatch error? Thanks!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,525

    Re: How to automate VBA Columnwidth using Named Ranges fields

    If both named ranges are single-cell, it seems that such a macro will suffice:
    Please Login or Register  to view this content.
    If both named ranges are multicellular, such a macro:
    Please Login or Register  to view this content.
    Artik
    Last edited by Artik; 06-26-2024 at 05:54 PM. Reason: Correcting a bug in the code

  3. #3
    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
    48,114

    Re: How to automate VBA Columnwidth using Named Ranges fields

    Untested, but try:

    Please Login or Register  to view this content.
    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


  4. #4
    Registered User
    Join Date
    12-08-2013
    Location
    United States
    MS-Off Ver
    Microsoft 365
    Posts
    69

    Re: How to automate VBA Columnwidth using Named Ranges fields

    Thank you so much Artik for your code, it worked successfully.

+ 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. [SOLVED] VBA creates named ranges, but named ranges disappear
    By BrotherNeptune in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-05-2015, 03:22 PM
  2. Define only 2 named ranges from a list of named ranges...
    By abhi900 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-29-2014, 04:20 AM
  3. Looping Mutliple Named Resized Ranges in next empty row below another named range
    By gingumdog in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-19-2014, 08:15 PM
  4. Replies: 0
    Last Post: 02-11-2010, 08:05 AM
  5. [SOLVED] Named ranges-is there a an easy way to reference a single value in a named range?
    By pspkim@gmail.com in forum Excel General
    Replies: 1
    Last Post: 03-21-2006, 06:40 PM
  6. Ranges of Named Fields
    By affordsol in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-19-2005, 12:05 PM
  7. Using named fields and ranges in macros
    By Bob Summers in forum Excel General
    Replies: 2
    Last Post: 05-05-2005, 09:48 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