I suspect the answer is no, but is there a way to copy/paste column widths without going via the clipboard?
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Copy Excel column widths via object
Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Copy Excel column widths via object
- This topic has 13 replies, 4 voices, and was last updated 13 years, 4 months ago.
AuthorTopicWSPaul Lautman
AskWoody LoungerNovember 23, 2011 at 7:15 am #480173Viewing 6 reply threadsAuthorReplies-
WSjscher2000
AskWoody Lounger -
WSPaul Lautman
AskWoody Lounger -
WSjscher2000
AskWoody LoungerNovember 23, 2011 at 11:13 am #1307891Well, one can do a copy via an object (i.e. not via the clipboard) using:
range_object.Copy Destination:=another_range_object
You’re right. I’ve never understood why copy/paste in Excel works differently within the application (more like “duplicate at destination”) than when you copy from Excel and paste to Word. But I digress.
You can add an additional line of code to set the column width:
Code:range_object.Copy Destination:=another_range_object another_range_object.ColumnWidth = range_object.ColumnWidth
Would that work for your actual procedure? It assumes a single column, which may be a very bad assumption.
Edit: This should work with multiple columns assuming the range is a rectangle (other scenarios might be a mess).
range_object.Copy Destination:=another_range_object
Dim intCount As Integer
For intCount = 1 To range_object.Columns.Count
another_range_object.Columns(intCount).ColumnWidth = range_object.Columns(intCount).ColumnWidth
Next[/code]
-
WSPaul Lautman
AskWoody Lounger-
WSjscher2000
AskWoody Lounger -
WSGary Frieder
AskWoody LoungerNovember 25, 2011 at 10:13 pm #1308097There is a Paste Special > Column Widths option in the user interface.
Recording a macro of applying that, results in (just including the key line here):Code:Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False
(substitute your range instead of Selection)
– would that work?
Gary
WSPaul Lautman
AskWoody Lounger-
WSGary Frieder
AskWoody LoungerNovember 29, 2011 at 9:36 pm #1308495No because it pastes from the clipboard which violates the “without going via the clipboard” in the OP.
Fair enough – just thought I’d throw that out there. Also to be fair, the OP’s original method:
Code:range_object.Copy Destination:=another_range_object
does use the clipboard (as far as I can tell). From Excel’s VBA Help topic:
Destination – Optional – Variant – Specifies the new range to which the specified range will be copied. If this argument is omitted, Microsoft Excel copies the range to the Clipboard.
– which doesn’t explicitly say that the clipboard is used when the argument is included, but a simple test seems to indicate it does:
Copy some ordinary text, and paste it anywhere (such as in a worksheet, or in a Word document). Then run the sample code from Excel’s Help topic:Code:Worksheets(“Sheet1”).Range(“A1:D4”).Copy destination:=Worksheets(“Sheet2”).Range(“E5”)
– and then try to repeat pasting the previously-copied text – nothing happens. So it seems like the Range Copy method is using (and clearing) the clipboard in some way.
In any case, Bob Flanagan’s suggestion seems best.
Gary
-
WSjscher2000
AskWoody Lounger
-
Anonymous
InactiveWSPaul Lautman
AskWoody Lounger-
WSGary Frieder
AskWoody Lounger
WSPaul Lautman
AskWoody LoungerNovember 30, 2011 at 10:01 am #1308570I think I was aware of that. Indeed immediately following that post I posted:
“I’ll try that.I already use another_range_object.value = range_object.value which does the equivalent of Paste Special Values on a whole range. It’s just a pity that there is no such shorthsnd for column widths.”
Viewing 6 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Slow Down in Windows 10 performance after March 2025 updates ??
by
arbrich
28 minutes ago -
Mail from certain domains not delivered to my outlook.com address
by
pumphouse
1 hour, 48 minutes ago -
Is data that is in OneDrive also taking up space on my computer?
by
WShollis1818
9 hours, 29 minutes ago -
Nvidia just fixed an AMD Linux bug
by
Alex5723
1 day, 3 hours ago -
50 years and counting
by
Susan Bradley
1 hour, 7 minutes ago -
Fix Bluetooth Device Failed to Delete in Windows Settings
by
Drcard:))
10 hours, 27 minutes ago -
Licensing and pricing updates for on-premises server products coming July 2025
by
Alex5723
1 day, 14 hours ago -
Edge : Deprecating window.external.getHostEnvironmentValue()
by
Alex5723
1 day, 14 hours ago -
Rethinking Extension Data Consent: Clarity, Consistency, and Control
by
Alex5723
1 day, 14 hours ago -
OneNote and MS Word 365
by
CWBillow
1 day, 16 hours ago -
Ultimate Mac Buyers Guide 2025: Which Mac is Right For You?
by
Alex5723
1 day, 16 hours ago -
Intel Unison support ends on Windows 11 in June
by
Alex5723
1 day, 17 hours ago -
April 2025 — still issues with AMD + 24H2
by
Kevin Jones
1 day, 17 hours ago -
Windows 11 Insider Preview build 26200.5518 released to DEV
by
joep517
2 days, 4 hours ago -
Windows 11 Insider Preview build 26120.3671 (24H2) released to BETA
by
joep517
2 days, 4 hours ago -
Forcing(or trying to) save Local Documents to OneDrive
by
PateWilliam
2 days, 13 hours ago -
Hotpatch for Windows client now available (Enterprise)
by
Alex5723
2 days, 1 hour ago -
MS-DEFCON 2: Seven months and counting
by
Susan Bradley
1 day, 2 hours ago -
My 3 monitors go black & then the Taskbar is moved to center monitor
by
saturn2233
2 days, 22 hours ago -
Apple backports fixes
by
Susan Bradley
2 days, 5 hours ago -
Win 11 24H2 will not install
by
Michael1950
1 day, 2 hours ago -
Advice to convert MBR to GPT and install Windows 11 Pro on unsupported PC
by
Andy M
12 minutes ago -
Photos from iPhone to Win 10 duplicating/reformatting to .mov
by
J9438
1 day, 11 hours ago -
Thunderbird in trouble. Here comes Thundermail
by
Alex5723
11 hours, 37 minutes ago -
Get back ” Open With” in context menus
by
CWBillow
3 days, 13 hours ago -
Many AMD Ryzen 9800X3D on ASRock have died
by
Alex5723
2 days, 5 hours ago -
simple general stupid question
by
WSaltamirano
3 days, 11 hours ago -
April 2025 Office non-Security updates
by
PKCano
4 days, 4 hours ago -
Microsoft wants to hear from you
by
Will Fastie
1 day, 19 hours ago -
Windows 11 Insider Preview Build 22635.5160 (23H2) released to BETA
by
joep517
4 days, 7 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.