Column Width

Hi Guys !!

I want to learn auto column width VBA application. When I enter data
in the column, column width should adjust according to size of DATA.
Can somebody help !  I will appreciate your efforts. Thanks in
advance.

0
Khan
5/1/2010 10:33:06 AM
excel.programming 6508 articles. 2 followers. Follow

3 Replies
1130 Views

Similar Articles

[PageSpeed] 59

Hi

This is an event code, so it has to be inserted into the codesheet for the 
desired sheet.  Also, the column width will never be less than 8:

Private Sub Worksheet_Change(ByVal Target As Range)
Target.EntireColumn.AutoFit
If Target.ColumnWidth < 8 Then
    Target.ColumnWidth = 8
End If
End Sub

Regards,
Per

"Khan" <aldehides@hotmail.com> skrev i meddelelsen 
news:34714810-ba5a-43fe-abe1-1c490e3c56ac@g21g2000yqk.googlegroups.com...
> Hi Guys !!
>
> I want to learn auto column width VBA application. When I enter data
> in the column, column width should adjust according to size of DATA.
> Can somebody help !  I will appreciate your efforts. Thanks in
> advance.
> 
0
Per
5/1/2010 11:19:30 AM
Hi,

Alt+F11 to open VB editor. Double click the worksheet you want this on and 
paste the code below in

Private Sub Worksheet_Change(ByVal Target As Range)
Columns(Target.Column).EntireColumn.AutoFit
End Sub
-- 
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that 
introduces the fewest assumptions while still sufficiently answering the 
question.


"Khan" wrote:

> Hi Guys !!
> 
> I want to learn auto column width VBA application. When I enter data
> in the column, column width should adjust according to size of DATA.
> Can somebody help !  I will appreciate your efforts. Thanks in
> advance.
> 
> .
> 
0
Utf
5/1/2010 11:47:01 AM
On May 1, 12:47=A0pm, Mike H <Mi...@discussions.microsoft.com> wrote:
> Hi,
>
> Alt+F11 to open VB editor. Double click the worksheet you want this on an=
d
> paste the code below in
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Columns(Target.Column).EntireColumn.AutoFit
> End Sub
> --
> Mike
>
> When competing hypotheses are otherwise equal, adopt the hypothesis that
> introduces the fewest assumptions while still sufficiently answering the
> question.
>
>
>
> "Khan" wrote:
> > Hi Guys !!
>
> > I want to learn auto column width VBA application. When I enter data
> > in the column, column width should adjust according to size of DATA.
> > Can somebody help ! =A0I will appreciate your efforts. Thanks in
> > advance.
>
> > .- Hide quoted text -
>
> - Show quoted text -

Dear Mike,

Thank you very much for this great help !

Khan
0
Khan
5/2/2010 7:33:24 AM
Reply:

Similar Artilces:

Stacked/clustered column chart with a two vertical axes
Much has been discussed here about how to build this chart, but I haven't found anything explaining the possibility of combining it with a second y axis. I want to graph the advertising expenditure and gross rating points (what would be the return of investment on advertising) on television for three diaper brands by day part. Day parts would be represented by the different colors of which columns will consist. There are 5 of them: day, early, prime, late and over. For each brand, I want that two data columns show. The one to the right will represent the expenditure in $ and the one to the...

Pivot Table Splits Columns for same entry #2
Thanks for the response. However, I seem to have misrepresented m problem because the solution doesn't help. In the Layout for the Pivo Table I have the following: In the "ROW": Item#, In the "COLUMN": Tota Lost $, Frequency of Reports generated by item #, In the "DATA": sum th counts of each item #. My chart displays the Item# on the x-axis, th sum the counts of each item # on the y-axis, the Total Lost $ and th Frequency of Reports generated by item # in the legend. There should only be one column per item # whether the chart type i stacked or clustered. I...

Help Please- How to offset Date to correct column for Ageing
Hi All, I have a stock ageing sheet for finished goods, which uses a vlookup table, on entry of the Product code (last 3 Digits), this populates the next three columns with description, FG cost and Quantity of product. the quantity of product is entered again manually into the appropriate column, there are five columns these are banded <3 Months 0%, 3 to 6 Months 25%, 6 to 9 months 50%, 9 to 12 Months 75% and > 1 Year 100%, the percentage is liability provision. What I would like to do is on entry of the product code as above the quantity is automatically inserted into the correc...

changing lookup columns
Anybody know a way to add a column to the LookUp screen for Accounts? When I am in a contact record and want to choose a parent account, I would like more columns to distinguish between the different accounts that come up. This isn't the Advanced Find or Associated View for Accounts so I can't see where to add the columns. I've even checked the QueryBase table and don't see any one that looks like it applies. Thanks. There is no supported way to do this in v.1x. Check this folder if you feel curious: \\CRMSERVER\c$\Inetpub\wwwroot\_controls\lookup\lookupxml "A...

Determine if Value in column A exists in Column B
Hello All- Simple question...I have a sheet with several hundred 10 digit numbers in column A and in Column B. I need a formula to put in column C, that will tell me if the number in A appears anywhere in the list of column B. Doesn't matter if the num,ber in column A appears more than once in column B, just if it appears anywere at all.. A B C 1 02020 02110 True (appears at B2) 2 01121 02020 False 3 01111 98981 False 4 02110 89789 True (appears at B1) 5 19982 58676 ...

Sorting Stacked Columns
I am trying to sort the columns so that the largest value is on th bottom each year. This would change the order of the series over eac year presumably. I have not figured out a way to do this, and fear i may be VBA related. Any ideas? Thanks. I attached the file for viewing Attachment filename: testbook_stackedcols.xls Download attachment: http://www.excelforum.com/attachment.php?postid=61644 -- Message posted from http://www.ExcelForum.com ...

Ungrouping columns
I was wondering if there was a way to ungroup a column in a bar graph from the others so I can put individual error bars on it. I can get error bars but it will put the same ones on all in that same group and that's not accurate for what I need. The way I have to have it set for presentation I can't do it any other way. If anyone can help it would be appreciated. Troy - You can put the error bar values into the worksheet, different values for each point, then in the Error Bars dialog, use the Custom definition to select the range containing these values. You can also spec...

Searching in a column of strings
Hi I try to find how many cells have a sequence of charcters. From Cell A1:A50. Exemple for "NY" : cellA1 = NY123 cellA2 = NY3235 cellA3 = NY5434 cellA4 = LA4234 function(NY) = 3 Like Seach but instead to be in a single cell, it's in a sequence of cell? Thanks Jack Jack =COUNTIF($A:$A,"*NY*") Regards Trevor "Jack" <anonymous@discussions.microsoft.com> wrote in message news:348501c3fd71$700c6c60$a001280a@phx.gbl... > > Hi > > I try to find how many cells have a sequence of > charcters. From Cell A1:A50. > > Exe...

Return to Column A #2
There was a post almost a month ago on this subject. The question posed was a good one though the answers returned didn't really answer the need. It's easy to move to the right on enter but how do you move to the next row and first column if you are at the end of the first row. Yes one can hit down arrow/home or Home/down arrow but this is a little annoying. If a sheet is protected and cells are locked, isn't there an easier way to do this more elegantly? Thanks in advance for your thoughts, Greg Say you start with A1 selected. Type something in A1 and hit the Tab key...

Adjusting Two Columns with Text
I have two columns. I've entered numbered text in each column. As I add more numbered items, the second column keeps adjusting itself downward. Is there anyway to freeze the second column as I add items to column one? I am not really sure what you mean by "the second column keeps adjusting itself downward". Do you have a two column table, or is the document formatted with columns? It sounds like you may have the former when what you want is the latter. Format the document so that it has two columns (via the Page Setup section of the Page Layout tab in Word 200...

Help...Need to modify data within a column in a .csv file
I have been given a .csv file of several thousand rows, and I need to change column A of each. The brief cutout below shows column A of the first two rows. (I need to skip the first row, which is the headers.) Kinda clumsy to have such a wide column, but the application this file is to be fed after I change the contents requires all the data separated by double-quotes to be in the one column. Cell A2: 09/12/0509/25/05"1417385"121"307"111-11-1111"09/30/05"LASTNAME1 Cell A3: 09/12/0509/25/05"1417386"101"900000005"222-22-2222"09/30/05"...

comparing columns of numbers
Hi If you have 2 columns of numbers and you want to find the numbers that are in one columns but not the other, and you type say A10=B10 then when you find a figure that is in one column but not the other you insert/delete a line and then drag the formula down again to keep checking. Is there any better formula I can use or anyway I can do it so I don't have to keep dragging down the formula Public Sub ProcessData() Const TestCol1 As String = "A" Const TestCol2 As String = "B" Dim i As Long Dim LastRow As Long With Application .ScreenUpdating = Fal...

How do I make column on the left side of Outlook[inbox,Sent etc.]
I want to add a column on the left side when I am in Outlook that shows (Inbox, Sent Items, Deleted items etc...) How is this done when in Outlook, Windows XP (SP3) Home Edition? "John" <John@discussions.microsoft.com> wrote in message news:6FA61CD3-8CE3-4DFA-B7B7-A27BCF0C29A6@microsoft.com... > I want to add a column on the left side when I am in Outlook that shows > (Inbox, Sent Items, Deleted items etc...) How is this done when in Outlook, > Windows XP (SP3) Home Edition? Enable the Navigation Pane. Press Alt+F1 or click View>Navigation Pane. ...

SQL statement to find a particular column within all tables
I am looking for a query that will allow me to find all instances of a particular column within all tables so I know where they are all located. Does anyone have such a query they would be willing to share? Thank you. Pam, I posted this query a few months aback on my blog (http://dynamicsgpblogster.blogspot.com/2008/03/in-past-days-i-have-found-lot-of-people.html), but here is the excerpt: select distinct rtrim(objs.name) from syscolumns cols inner join sysobjects objs on (cols.id = objs.id) inner join sysindexes indx on (cols.id = indx.id) where (cols.name = 'ACTINDX') and (ob...

delete rows when any cells in column A is filled in RED color
Hi people, I need your help for a VB code that can delete the rows with any cells in column A being filled in RED color ? Alternatively, it will be fine for me if you have the code that can move the rows to the top when there are cells being filled in RED color in column A . Thanks in advance for help. ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ ~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements If the colors are ...

how do I create a chart on two axes with stacked columns and line
I am struggling to create a chart that combines stacked columns on one X axis with a line on a second axis. Both are available as standard charts. Hi, Create the stacked column chart with all of your data. Select the data series you want to plot as a line on the secondary axis. Change the chart type to line. And then on the format dialog change the axis to the secondary. Cheers Andy ian ian ian rogers wrote: > I am struggling to create a chart that combines stacked columns on one X axis > with a line on a second axis. Both are available as standard charts. -- Andy Pope, Microso...

copy an intial cells contents into the next series of blank cells in a column
When doing a pivot table, the data in a column might have the initial cell inditifer, such as a date and the remaining cells if they have the same date will be blank. I know there is a process that you can highlight the cells in a range and have copied the initial cell into the next suceeding blank cells, I just don't remember the sequence of steps to get there. can anybod help? Select the column with data. F5>Special>Blanks>OK Type an = sign in active blank cell. Arrow or point to cell above. CTRL + Enter to fill all blanks with value from above. Gord Dibben MS Excel MV...

append multiple columns
I have a time consuming task and was trying to find a way to append multiple columns of data (with blank cells) under column "A". Currently, my columns have data out to column "M", but this may increase or decrease. From: A B C etc. Thru Column "M" 1 Data1 2 Data 2 3 Data 3 Data X 4 Data 4 Data Z 5 Data 5 6 Data 6 Data Y Into: A B C etc. Thru Column "M" 1 Data1 2 Data 2 3 Data 3 4 D...

Convert column # to the letter of the alphabet
In the following code the uCol value is a number, I need the actual column letter. Is there an easy way to convert the # to the correct column letter. I could us an array or a function with a select case but I have at least 180 columns that have to be done. The code is used to determine the location of a particular Agent's sales data for poping up a chart using that data. uAdd = ActiveWindow.RangeSelection.Address uCol = Range(uAdd).Column Thanks! Try this... uAdd = ActiveWindow.RangeSelection.Address(1, 0) uCol = Split(uAdd, "$")(0) -- Rick (MVP - E...

include more than 3 data series as columns in combination chart
I am making a combination chart and am only able to include the first 3 data series with the column chart part. The rest of the series are all included with the second series which has a much larger value. On Tue, 26 Jun 2007, in microsoft.public.excel.charting, Cindy <Cindy@discussions.microsoft.com> said: >I am making a combination chart and am only able to include the first 3 data >series with the column chart part. The rest of the series are all included >with the second series which has a much larger value. Ignore "combination" charts, you don't need the ...

Sum of all formulas in one column?
Is there some automatic way to make Excel total all of the cells containing formulas in a column? I know about the Subtotals feature, and being a new user, I can't quite figure out how to work it. I got to thinking if there is some easy formula that SUMs the results of all formulas in the same column, that would do exactly what I want it to do. Right now, all I'm doing to create a grand total is creating a formula manually to give me my grand total, i.e. =SUM(C5,C11,C18). However, if I'm going to add rows with subtotals in between each of my categories, I'll have to manu...

How do i make the column headings show everywhere
I need to know how to make the headings for the columns in excell show at the top nomatter where you scrol in the spreadsheet. Thanks- Thomas Thomas, Select a cell below your column headings, and to the right of any cells that should also remain onscreen as the user scrolls. Window - Freeze panes. -- Earl Kiosterud mvpearl omitthisword at verizon period net ------------------------------------------- "Thomas" <Thomas@discussions.microsoft.com> wrote in message news:26BBCCDA-F0C0-4874-9B05-5CDF9A68B46A@microsoft.com... > I need to know how to make the headings for the ...

looking up the last value in a column
I need assistance in choosing the correct function so that I can obtain the last calculated value in a column range as each month another value is added to the list. =LOOKUP(9.99999999999999E+307,A:A) would fetch the last numerical value from column A. Bob wrote: > I need assistance in choosing the correct function so that I can obtain the > last calculated value in a column range as each month another value is added > to the list. Dear Aladin Thanks for your reply however this did not solve my problem. The column (T) contains formulas which are dependent to other cells so ...

Formula to average last 25 entries in a column?
Guess I have a duel question. First, I have numerous columns of data, all numerical. New entries are entered at the end of the column. Is there a formula to average just the last 25 entries in the column? (Bottom of column up) Second question pertains to the ability to "auto populate". I have a column of names. (three dozen). I would then like to auto populate the single column of names, matching the names with the average data obtained from the above. (average of last 25, 50, 100,etc entries) Data changes daily? Any help would be greatly appreciated. Hi, A...

Preventing Duplicate Entries within a column
Is there an easy way to prevent creating duplicate entries within a given column in Excel? Alternately....is there a way to automatcially highlight a cell / row when a duplicate entry is created within a given column? If they are typed in yes it is easy http://www.cpearson.com/excel/NoDupEntry.htm or to tag them http://www.cpearson.com/excel/duplicat.htm Regards, Peo Sjoblom "Bruce" wrote: > Is there an easy way to prevent creating duplicate > entries within a given column in Excel? > Alternately....is there a way to automatcially highlight > a cell ...