I suspect the answer is no, but is there a way to copy/paste column widths without going via the clipboard?
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
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, 3 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
-
Updating Windows 10 to Windows 11: 23H2 or 24H2?
by
Still Anonymous
2 hours, 14 minutes ago -
How can I update “Explorer Patcher”
by
WSplanckster
4 hours, 7 minutes ago -
Check out the home page for Signal
by
CAS
2 hours ago -
Windows 11 and Trial version of MS Office
by
Tex265
1 hour, 3 minutes ago -
Windows 11 Insider Preview build 26120.3585 (24H2) released to BETA
by
joep517
8 hours, 31 minutes ago -
Windows 11 Insider Preview build 26200.5510 released to DEV
by
joep517
8 hours, 34 minutes ago -
Windows 11 Insider Preview Build 26100.3624 (24H2) released to Release Preview
by
joep517
8 hours, 38 minutes ago -
Limits on User Names
by
CWBillow
5 hours, 20 minutes ago -
MS-DEFCON 4: Mixed bag for March
by
Susan Bradley
4 minutes ago -
Non Apple Keyboards
by
pmcjr6142
2 hours, 42 minutes ago -
How to delete your 23andMe data – The Verge
by
AJNorth
3 hours, 17 minutes ago -
7 common myths about Windows 11 (Microsoft AD)
by
EyesOnWindows
53 minutes ago -
Error updating to Win11 0x8024a205
by
bmeacham
1 day, 2 hours ago -
default apps
by
chasfinn
1 day, 2 hours ago -
Will MS Works 4 work in MS Win 11?
by
MileHighFlyer
1 day, 10 hours ago -
Adding links to text in Word 2000
by
sgeneris
7 hours, 34 minutes ago -
FBI warnings are true—fake file converters do push malware
by
Nibbled To Death By Ducks
1 day, 4 hours ago -
Classic and Extended Control Panel — no need to say goodbye
by
Deanna McElveen
6 hours, 16 minutes ago -
Things you can do in 2025 that you couldn’t do in 2024
by
Max Stul Oppenheimer
1 day, 15 hours ago -
Revisiting Windows 11’s File Explorer
by
Will Fastie
23 hours, 52 minutes ago -
Planning ahead for migration
by
Susan Bradley
9 minutes ago -
Yahoo mail getting ornery
by
Tom in Az
1 day, 2 hours ago -
Is Spectrum discontinuing email service?
by
Peobody
1 day, 6 hours ago -
Practice what you preach! A cautionary tale.
by
RetiredGeek
1 day, 2 hours ago -
Looking for Microsoft Defender Manuals/Tutorial
by
blueboy714
1 day, 6 hours ago -
Win 11 24H2 Home or Pro?
by
CWBillow
1 day, 3 hours ago -
Bipartisan Effort to Sunset the ‘26 Words That Created the Internet’..
by
Alex5723
3 days, 13 hours ago -
Outlook new and edge do not load
by
cHJARLES a pECKHAM
4 days, 1 hour ago -
Problem using exfat drives for backup
by
Danmc
4 days, 1 hour ago -
I hate that AI is on every computer we have!
by
1bumthumb
3 days, 3 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.