Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Using Code to Adjust Specific Column Width

I have a spreadsheet that retrieves data after it has
retreived the data I want to use code to look in row 5 and
go thru each cell up to the last colum, if there is
nothing in the cell I want it to resize it to a smaller
size,

is there anyway of doing this

Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Using Code to Adjust Specific Column Width


If Application.COUNTA(Range("C:C") = 0 Then
Range("C:C").ColumnWidth = 5
End If

--
HTH

Bob Phillips

"Nigel Bennett" wrote in message
...
I have a spreadsheet that retrieves data after it has
retreived the data I want to use code to look in row 5 and
go thru each cell up to the last colum, if there is
nothing in the cell I want it to resize it to a smaller
size,

is there anyway of doing this

Thanks




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Using Code to Adjust Specific Column Width

Could you explain the range definition for me please
-----Original Message-----

If Application.COUNTA(Range("C:C") = 0 Then
Range("C:C").ColumnWidth = 5
End If

--
HTH

Bob Phillips

"Nigel Bennett" wrote in message
...
I have a spreadsheet that retrieves data after it has
retreived the data I want to use code to look in row 5

and
go thru each cell up to the last colum, if there is
nothing in the cell I want it to resize it to a smaller
size,

is there anyway of doing this

Thanks


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Using Code to Adjust Specific Column Width


No the code didn't work I had the following entered

If application.CountA(range("A5,CG5")) = 0 Then
range("A5,CG5").ColumnWidth = 5
End If

any help


-----Original Message-----

If Application.COUNTA(Range("C:C") = 0 Then
Range("C:C").ColumnWidth = 5
End If

--
HTH

Bob Phillips

"Nigel Bennett" wrote in message
...
I have a spreadsheet that retrieves data after it has
retreived the data I want to use code to look in row 5

and
go thru each cell up to the last colum, if there is
nothing in the cell I want it to resize it to a smaller
size,

is there anyway of doing this

Thanks




.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Using Code to Adjust Specific Column Width

How about the following:


Dim Rng As Range
Dim oCell As Range
Dim LastCol As Range

Set LastCol = Cells(5, Columns.Count).End(xlToLeft)
Set Rng = Range(Cells(5, 1), LastCol)

For each oCell in Rng
If oCell="" then oCell.ColumnWidth=5
Next oCell


"Nigel Bennett" wrote:

I have a spreadsheet that retrieves data after it has
retreived the data I want to use code to look in row 5 and
go thru each cell up to the last colum, if there is
nothing in the cell I want it to resize it to a smaller
size,

is there anyway of doing this

Thanks



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
Column Width: cannot adjust falcios Excel Discussion (Misc queries) 1 November 3rd 07 02:49 PM
column width will not adjust Bold, Underling and Italics errors Excel Worksheet Functions 1 October 22nd 07 10:51 PM
Adjust column width tlee Excel Discussion (Misc queries) 2 May 4th 06 11:58 PM
Adjust Column Width? CDAK Excel Discussion (Misc queries) 0 June 16th 05 10:26 PM
adjust column width coolbeans Excel Discussion (Misc queries) 1 May 15th 05 12:34 PM


All times are GMT +1. The time now is 05:08 AM.

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

About Us

"It's about Microsoft Excel"