Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default set a column length


I need to make column D in my database equal to the number of records i
column B, which will change each time I update the data or change th
search criterea. How exactly do I go about this? This is the what
have now but it brings me the files themselve from B and not the lengt
which is what I want.

Stephe
Pear

--
spear
-----------------------------------------------------------------------
speary's Profile: http://www.excelforum.com/member.php...fo&userid=2495
View this thread: http://www.excelforum.com/showthread.php?threadid=38487

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default set a column length

This bit of code is fairly straight forward, basically it counts the records
in column B down to the last record and then widens the D column to that
width. So if there were 10 records in column B, column D becomes 10 in width

Dim rcount As Integer

Range("B:B").Select
Range(Selection, Selection.End(xlDown)).Select

For Each cell In Selection
rcount = rcount + 1
Next cell

Columns("D:D").Select
Selection.ColumnWidth = rcount



"speary" wrote:


I need to make column D in my database equal to the number of records in
column B, which will change each time I update the data or change the
search criterea. How exactly do I go about this? This is the what i
have now but it brings me the files themselve from B and not the length
which is what I want.

Stephen
Peary


--
speary
------------------------------------------------------------------------
speary's Profile: http://www.excelforum.com/member.php...o&userid=24959
View this thread: http://www.excelforum.com/showthread...hreadid=384878


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default set a column length


It still seems to set a column length un equal to column 'b'. Is there a
place that I should add the formula to so that it sets the column length
when i first enter in my infor to VB..i tired running it after i had
completed my previous macro but it still had "0"'s going all the way to
the bottom of the spreadsheet b/c i must have copied the formula down
the entire column. How would I copy it just to the end of the number of
rows that contain information. for example:

If column b has 20 rows....so would column d


but in sheet 2

column b has 30 rows....so therefor column d has the same number


--
speary
------------------------------------------------------------------------
speary's Profile: http://www.excelforum.com/member.php...o&userid=24959
View this thread: http://www.excelforum.com/showthread...hreadid=384878

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default set a column length


thanks to everyone for your responses...but all the options seem not t
work. Most return error messages. Maybe I am not explaining it right
am not sure, i am new to this visual basic stuff in excel. I guess wha
i wanted to do was make the number of rows in colum b equal the numbe
of rows in column d in 3 different sheets. Number of rows in column
has to equal b as well. I'm not sure if this helps or not but thank
again for responding

--
spear
-----------------------------------------------------------------------
speary's Profile: http://www.excelforum.com/member.php...fo&userid=2495
View this thread: http://www.excelforum.com/showthread.php?threadid=38487



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default set a column length

Speary, I think part of the issue, is im not really sure what you are
explaining. In Excel all columns are equally laid out, so column B will
always have the same amount of rows as column D, unless you merge cells.

Do you mean that there are 20 rows worth of data in column B? So that B1:B20
have information in each cell? If thats the case do you want that exact
information in Column D? Perhaps show us an example of what you are trying to
do.

"speary" wrote:


It still seems to set a column length un equal to column 'b'. Is there a
place that I should add the formula to so that it sets the column length
when i first enter in my infor to VB..i tired running it after i had
completed my previous macro but it still had "0"'s going all the way to
the bottom of the spreadsheet b/c i must have copied the formula down
the entire column. How would I copy it just to the end of the number of
rows that contain information. for example:

If column b has 20 rows....so would column d


but in sheet 2

column b has 30 rows....so therefor column d has the same number


--
speary
------------------------------------------------------------------------
speary's Profile: http://www.excelforum.com/member.php...o&userid=24959
View this thread: http://www.excelforum.com/showthread...hreadid=384878


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default set a column length


it seems to be working now...i hope. I definately wasn't explaining it
right, i have minimal computer knowledge and tend to confuse terms or
use them interchangable. sorry for the confusion but thanks for the
suggestions they got me on the right track.

Stephen Peary


--
speary
------------------------------------------------------------------------
speary's Profile: http://www.excelforum.com/member.php...o&userid=24959
View this thread: http://www.excelforum.com/showthread...hreadid=384878

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default set a column length


Columns("F:F").Select
Selection.INSERT Shift:=xlToRight

Range("E1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Range("F1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
SkipBlanks _
:=False, Transpose:=False
Columns("D:D").Select
Application.CutCopyMode = False
Selection.delete Shift:=xlToLeft
Columns("D:D").Select
Selection.delete Shift:=xlToLeft




Like I said this seemed to work for me to make it so I had an equa
number or data cells in each column. Before I had zero's going all th
to the last cell on the spreadsheet in column e after the data ended i
in column d. before I couldnt get the

Range(selection,selection.end(x1down)).select line to work it kept o
giving me error messages.

That was basically what i was trying to ask in my original question wh
that error message kept coming up

--
spear
-----------------------------------------------------------------------
speary's Profile: http://www.excelforum.com/member.php...fo&userid=2495
View this thread: http://www.excelforum.com/showthread.php?threadid=38487



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
automate column length wsk Excel Discussion (Misc queries) 1 May 13th 06 12:31 PM
Sum a Column of Variable length Chris G Excel Discussion (Misc queries) 4 November 7th 05 12:25 PM
How to column length into a formula Kanga 85 Excel Programming 2 March 13th 05 12:27 AM
Sum a column of variable length? Brian Excel Discussion (Misc queries) 5 February 3rd 05 02:26 PM
Length of Used Column Alec Excel Programming 2 October 21st 03 03:52 PM


All times are GMT +1. The time now is 03:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"