![]() |
|
#1
|
||||
|
||||
![]() I see something in your program that makes me afraid to try it for myself, but I think I can describe it and you tell me whether I'm mistaken. 1) First step makes sense; you're getting the width of the two columns: totalWidth = Columns("b").ColumnWidth + Columns("c").ColumnWidth 2) I don't understand this part: You start a loop, and tell it to go on doing it over and over as long as your selection takes in cells in exactly two columns. But I don't see that anything inside the loop changes that selection, so the program will go on running, redoing the loop again and again. Do While Selection.Columns.Count = 2 3) What you do inside the loop looks like it started out to make sense: You want to adjust the width of column C to make B+C come out to the desired width. Looks to me, though, as if you made it actually come out to the same width it already was. That's because you're using the actual width instead of the desired width: columnBWidth = Columns("b").ColumnWidth 4) I also don't get what the Wait statement is for, but I don't think it's hurting anything. Excel seems to freeze, as I see it, because it's running the loop over and over again. Here's what I would do: Code:
Sub CommandButton1_Click() Columns(3).ColumnWidth = 539 - Columns(2).ColumnWidth End Sub |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
CrossReach | Word | 4 | 03-13-2016 10:49 AM |
![]() |
Suppy | PowerPoint | 2 | 01-27-2015 02:15 AM |
How to adjust Image size and other question | arjfca | Word VBA | 1 | 12-05-2014 02:00 AM |
![]() |
mejnik | PowerPoint | 1 | 04-04-2014 09:12 AM |
![]() |
Gary Drumm | Windows | 2 | 03-31-2014 08:22 AM |