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, 6 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
-
What goes on inside an LLM
by
Michael Covington
1 hour, 32 minutes ago -
The risk of remote access
by
Susan Bradley
3 hours, 4 minutes ago -
The cruelest month for many Office users
by
Peter Deegan
3 hours, 5 minutes ago -
Tracking protection and trade-offs in Edge
by
Mary Branscombe
3 hours, 6 minutes ago -
Supreme Court grants DOGE access to confidential Social Security records
by
Alex5723
3 hours, 8 minutes ago -
EaseUS Partition Master free 19.6
by
Alex5723
4 hours, 6 minutes ago -
Microsoft : Edge is better than Chrome
by
Alex5723
16 hours, 24 minutes ago -
The EU launched DNS4EU
by
Alex5723
1 day, 5 hours ago -
Cell Phone vs. Traditional Touchtone Phone over POTS
by
280park
19 hours, 27 minutes ago -
Lost access to all my networked drives (shares) listed in My Computer
by
lwerman
1 day, 10 hours ago -
Set default size for pasted photo to word
by
Cyn
1 day, 16 hours ago -
Dedoimedo tries 24H2…
by
Cybertooth
1 day, 4 hours ago -
Windows 11 Insider Preview build 27871 released to Canary
by
joep517
2 days, 15 hours ago -
Windows 11 ad from Campaign Manager in Windows 10
by
Jim McKenna
8 hours, 19 minutes ago -
Small desktops
by
Susan Bradley
7 hours, 25 minutes ago -
Totally disable Bitlocker
by
CWBillow
1 day, 9 hours ago -
Phishers extract Millions from HMRC accounts..
by
Microfix
2 days, 13 hours ago -
Windows 10 22H2 Update today (5 June) says up-to-date but last was 2025-04
by
Alan_uk
3 days, 19 hours ago -
Thoughts on Malwarebytes Scam Guard for Mobile?
by
opti1
1 day, 14 hours ago -
Mystical Desktop
by
CWBillow
3 days, 22 hours ago -
Meta and Yandex secretly tracked billions of Android users
by
Alex5723
3 days, 4 hours ago -
MS-DEFCON 2: Do you need that update?
by
Susan Bradley
15 hours, 24 minutes ago -
CD/DVD drive is no longer recognized
by
WSCape Sand
4 days, 14 hours ago -
Windows 11 24H2 Default Apps stuck on Edge and Adobe Photoshop
by
MikeBravo
4 days, 16 hours ago -
North Face and Cartier customer data stolen in cyber attacks
by
Alex5723
4 days, 14 hours ago -
What is wrong with simple approach?
by
WSSpoke36
2 days, 13 hours ago -
Microsoft-Backed Builder.ai Set for Bankruptcy After Cash Seized
by
Alex5723
5 days, 2 hours ago -
Location, location, location
by
Susan Bradley
3 days, 16 hours ago -
Cannot get a task to run a restore point
by
CWBillow
5 days, 3 hours ago -
Frustrating search behavior with Outlook
by
MrJimPhelps
4 days, 18 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.