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, 5 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
Inactive -
WSPaul 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
-
Sometimes I wonder about these bots
by
Susan Bradley
2 hours, 56 minutes ago -
Does windows update component store “self heal”?
by
Mike Cross
4 hours, 54 minutes ago -
Windows 11 Insider Preview build 27858 released to Canary
by
joep517
5 hours, 54 minutes ago -
Pwn2Own Berlin 2025: Day One Results
by
Alex5723
5 hours, 19 minutes ago -
Windows 10 might repeatedly display the BitLocker recovery screen at startup
by
Susan Bradley
1 hour, 49 minutes ago -
Windows 11 Insider Preview Build 22631.5409 (23H2) released to Release Preview
by
joep517
8 hours, 36 minutes ago -
Windows 10 Build 19045.5912 (22H2) to Release Preview Channel
by
joep517
8 hours, 37 minutes ago -
Kevin Beaumont on Microsoft Recall
by
Susan Bradley
2 hours, 30 minutes ago -
The Surface Laptop Studio 2 is no longer being manufactured
by
Alex5723
16 hours, 45 minutes ago -
0Patch, where to begin
by
cassel23
10 hours, 47 minutes ago -
CFPB Quietly Kills Rule to Shield Americans From Data Brokers
by
Alex5723
1 day, 6 hours ago -
89 million Steam account details just got leaked,
by
Alex5723
18 hours, 8 minutes ago -
KB5058405: Linux – Windows dual boot SBAT bug, resolved with May 2025 update
by
Alex5723
1 day, 14 hours ago -
A Validation (were one needed) of Prudent Patching
by
Nibbled To Death By Ducks
1 day, 5 hours ago -
Master Patch Listing for May 13, 2025
by
Susan Bradley
17 hours, 2 minutes ago -
Installer program can’t read my registry
by
Peobody
6 minutes ago -
How to keep Outlook (new) in off position for Windows 11
by
EspressoWillie
1 day, 3 hours ago -
Intel : CVE-2024-45332, CVE-2024-43420, CVE-2025-20623
by
Alex5723
1 day, 11 hours ago -
False error message from eMClient
by
WSSebastian42
2 days, 2 hours ago -
Awoke to a rebooted Mac (crashed?)
by
rebop2020
2 days, 11 hours ago -
Office 2021 Perpetual for Mac
by
rebop2020
2 days, 12 hours ago -
AutoSave is for Microsoft, not for you
by
Will Fastie
1 day, 8 hours ago -
Difface : Reconstruction of 3D Human Facial Images from DNA Sequence
by
Alex5723
2 days, 15 hours ago -
Seven things we learned from WhatsApp vs. NSO Group spyware lawsuit
by
Alex5723
1 day, 16 hours ago -
Outdated Laptop
by
jdamkeene
2 days, 21 hours ago -
Updating Keepass2Android
by
CBFPD-Chief115
3 days, 2 hours ago -
Another big Microsoft layoff
by
Charlie
3 days, 2 hours ago -
PowerShell to detect NPU – Testers Needed
by
RetiredGeek
4 hours, 31 minutes ago -
May 2025 updates are out
by
Susan Bradley
6 hours, 13 minutes ago -
Windows 11 Insider Preview build 26200.5600 released to DEV
by
joep517
3 days, 8 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.