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, 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
-
Is there a comprehensve way to tranfer ALL current Edge Settings into a new Edge
by
Tex265
40 minutes ago -
Transferring ALL info/settings from current Firefox to new computer Firefox
by
Tex265
1 minute ago -
DOGE Wants to Replace SSA 60 Million Line COBOL Codebase in Months
by
EyesOnWindows
1 hour, 35 minutes ago -
KB5051989 Usb printer Post Ipp
by
licencesti
1 hour, 46 minutes ago -
Removing bypassnro
by
Susan Bradley
13 minutes ago -
Up to 30 seconds to show “Recent Topics”
by
PL1
43 minutes ago -
Sound changes after upgrade from W11 23H2
by
WStaylorpsepa
2 hours, 27 minutes ago -
Windows bug blocks BIOS updates for Lenovo ThinkPad laptops
by
Alex5723
5 hours, 29 minutes ago -
O&O Software – ‘World Backup Day’ Sale
by
unbob
1 hour, 49 minutes ago -
Still version 23H2?
by
WSbxcfilm
6 hours, 17 minutes ago -
Ubuntu 25.04 (Plucky Puffin) Beta released
by
Alex5723
12 hours, 14 minutes ago -
How to install App Store apps on an external SSD
by
Alex5723
13 hours, 8 minutes ago -
Where is Windows going?
by
Susan Bradley
3 hours, 25 minutes ago -
Installing Feature Update Windows 11 24H2
by
geekdom
1 day, 6 hours ago -
Windows 11 Insider Preview build 27823 released to Canary
by
joep517
1 day, 7 hours ago -
Windows 11 Hotpatch
by
Hackmuss
14 hours, 18 minutes ago -
System Guard service error still won’t be fixed
by
Susan Bradley
1 day, 7 hours ago -
Operation ForumTroll: APT attack with Google Chrome zero-day exploit chain
by
Alex5723
1 day, 1 hour ago -
Troy Hunt of HaveIBeenPwned Phished
by
Lars220
22 hours, 51 minutes ago -
Microsoft Windows security auditing Code 5061
by
mpw
1 day, 20 hours ago -
Can’t display images in incoming Outlook 365 emails
by
WScopwriter
1 day, 3 hours ago -
Windows 11 Insider Preview Build 26200.5510 early builds of 25H2
by
Alex5723
1 day, 5 hours ago -
0Patch : Micropatches released for SCF File NTLM Hash Disclosure Vulnerability
by
Alex5723
1 day, 4 hours ago -
Select multiple emails and they all open up!
by
CeeJay
2 days, 21 hours ago -
How to remove an update preview
by
Gunny
1 day ago -
Third party add ins reminder
by
Susan Bradley
6 hours, 51 minutes ago -
OTF, which backs Tor, Let’s Encrypt and more, sues to save its funding
by
Nibbled To Death By Ducks
2 days, 15 hours ago -
Updating Windows 10 to Windows 11: 23H2 or 24H2?
by
Still Anonymous
3 days, 1 hour ago -
How can I update “Explorer Patcher”
by
WSplanckster
3 days, 3 hours ago -
Check out the home page for Signal
by
CAS
3 days, 1 hour ago
Recent blog posts
- Removing bypassnro
- Where is Windows going?
- System Guard service error still won’t be fixed
- Third party add ins reminder
- MS-DEFCON 4: Mixed bag for March
- Classic and Extended Control Panel — no need to say goodbye
- Things you can do in 2025 that you couldn’t do in 2024
- Revisiting Windows 11’s File Explorer
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.