Additionally, although it is quite possible to detect when one of the
data-val. cells has been selected, perform a task, then when another cell's
been selected, reverse the original task (mburkett -- you'll need to track
some data between events to do that), your code then has to figure out how
wide to make the cell.  There is not exactly accuarate way to calculate how
wide a cell needs to be based on text not in the cell.  The only accurate
and reliable way is to use autofit on the column after placing the text in
the cell.  You could have your code do that -- taking care to avoid unwanted
side effects (like triggering another event that takes an unwanted action)
to measure the text.  Actually, if you really wanted to, you could do place
the text in some OTHER cell and measure it that way.  You might guess that
the longest string of text on the DV list will take up the most space, but
not necessarily.  So to be sure, you'd have to measure all the values to
find the width you want.  This might take a noticable amount of time, so you
could calculate and store in the workbook the corresponding widths along
with the DV values, which you might calculate in a Change event whenever
those DV values are changed, instead of every time a DV cell is selected.

 

It's not a short simple answer.  Sorry I haven't coded a solution, but
perhaps my analysis is helpful.  I can go into greater detail if you have
questions (mburkett), but probably won't have time to work on it.

 

Asa

 

 

 

From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
On Behalf Of Paul Schreiner
Sent: Friday, August 31, 2012 12:18 PM
To: excel-macros@googlegroups.com
Subject: Re: $$Excel-Macros$$ Change Column Size

 

>From his description, I think he's looking for something like a
SelectionChange Event.

Where, when he selects the cell with the pull-down, it automatically changes
the width of the column to ##.

Then, when a different cell is selected, the column returns to it's original
width.
 

Paul

-----------------------------------------
"Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can." - John Wesley
-----------------------------------------

 

 

  _____  

From: NOORAIN ANSARI <noorain.ans...@gmail.com>
To: excel-macros@googlegroups.com
Sent: Fri, August 31, 2012 2:33:54 PM
Subject: Re: $$Excel-Macros$$ Change Column Size

Without VBa Code
you can use..

Alt+O+C+A

On Fri, Aug 31, 2012 at 11:44 PM, NOORAIN ANSARI <noorain.ans...@gmail.com>
wrote:

Dear Mburket,

You can use..


Sub column_fit()
Cells.Columns.AutoFit
End Sub 

 

On Fri, Aug 31, 2012 at 11:41 PM, mburkett <michaelburk...@gmail.com> wrote:

I am using a list with data validation in cells c64:c74. The choices are
very long text strings. Does anyone have code that will expand the column
width when I select any of the cells and return to original (or specific)
size once deselected? 

-- 
Join official facebook page of this forum @
https://www.facebook.com/discussexcel
 
FORUM RULES (1120+ members already BANNED for violation)
 
1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.
 
2) Don't post a question in the thread of another member.
 
3) Don't post questions regarding breaking or bypassing any security
measure.
 
4) Acknowledge the responses you receive, good or bad.
 
5) Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 
 
6) Jobs posting is not allowed.
 
7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed.
 
NOTE : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups
"MS EXCEL AND VBA MACROS" group.
To post to this group, send email to excel-macros@googlegroups.com.
To unsubscribe from this group, send email to
excel-macros+unsubscr...@googlegroups.com
<mailto:excel-macros%2bunsubscr...@googlegroups.com> .
 
 





-- 
With Regards,
Noorain Ansari
 <http://www.noorainansari.com/> http://noorainansari.com
<http://www.noorainansari.com/> 
 <http://www.excelvbaclinic.blogspot.com/> http://excelvbaclinic.com
<http://www.excelvbaclinic.blogspot.com/>  

 

 




-- 
With Regards,
Noorain Ansari
 <http://www.noorainansari.com/> http://noorainansari.com
<http://www.noorainansari.com/> 
 <http://www.excelvbaclinic.blogspot.com/> http://excelvbaclinic.com
<http://www.excelvbaclinic.blogspot.com/>  

 

 

-- 
Join official facebook page of this forum @
https://www.facebook.com/discussexcel
 
FORUM RULES (1120+ members already BANNED for violation)
 
1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.
 
2) Don't post a question in the thread of another member.
 
3) Don't post questions regarding breaking or bypassing any security
measure.
 
4) Acknowledge the responses you receive, good or bad.
 
5) Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 
 
6) Jobs posting is not allowed.
 
7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed.
 
NOTE : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups
"MS EXCEL AND VBA MACROS" group.
To post to this group, send email to excel-macros@googlegroups.com.
To unsubscribe from this group, send email to
excel-macros+unsubscr...@googlegroups.com.
 
 

-- 
Join official facebook page of this forum @
https://www.facebook.com/discussexcel
 
FORUM RULES (1120+ members already BANNED for violation)
 
1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.
 
2) Don't post a question in the thread of another member.
 
3) Don't post questions regarding breaking or bypassing any security
measure.
 
4) Acknowledge the responses you receive, good or bad.
 
5) Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 
 
6) Jobs posting is not allowed.
 
7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed.
 
NOTE : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups
"MS EXCEL AND VBA MACROS" group.
To post to this group, send email to excel-macros@googlegroups.com.
To unsubscribe from this group, send email to
excel-macros+unsubscr...@googlegroups.com.
 
 

-- 
Join official facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES (1120+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

6) Jobs posting is not allowed.

7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed.

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To post to this group, send email to excel-macros@googlegroups.com.
To unsubscribe from this group, send email to 
excel-macros+unsubscr...@googlegroups.com.


Reply via email to