Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default column width and row height formatting, & IF

Hi all.
I've recorded a macro, and in part of it I want to look at a specific group
of columns' widths.
I.e., I want to know if a column is less than a standard, or predetermined
width, and if so, delete that column. Someone has placed a series of "buffer"
columns to act as spacers, and they're unnecessary for our purposes, so I
want to delete them, and doing this by hand is really time consuming.
I've read some of the posts, and I'm wondering if the following will work.

dim MyCol as range

if MyCol.columnwidth<X 'where X is my choice of width.

myCol.select

Selection.Delete Shift:=xlToLeft

end if

Similarly, I want to do something identical with row heights.
would
dim MyRow as range

if MyRow.rowheight < Y 'where Y is my predetermined height value

MyRow.select
Selection.Delete Shift:=xlUp
end if


Thanks for your responses.
Best.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default column width and row height formatting, & IF

Give this code a try (substitute the width you want to compare to for the
8.43 width I used)...

Sub RemoveNarrowColumns()
Dim X As Long
For X = Columns.Count To 1 Step -1
If Columns(X).ColumnWidth < 8.43 Then Columns(X).Delete
Next
End Sub

Rick


"SteveDB1" wrote in message
...
Hi all.
I've recorded a macro, and in part of it I want to look at a specific
group
of columns' widths.
I.e., I want to know if a column is less than a standard, or predetermined
width, and if so, delete that column. Someone has placed a series of
"buffer"
columns to act as spacers, and they're unnecessary for our purposes, so I
want to delete them, and doing this by hand is really time consuming.
I've read some of the posts, and I'm wondering if the following will work.

dim MyCol as range

if MyCol.columnwidth<X 'where X is my choice of width.

myCol.select

Selection.Delete Shift:=xlToLeft

end if

Similarly, I want to do something identical with row heights.
would
dim MyRow as range

if MyRow.rowheight < Y 'where Y is my predetermined height value

MyRow.select
Selection.Delete Shift:=xlUp
end if


Thanks for your responses.
Best.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default column width and row height formatting, & IF

Sorry, missed your 2nd question regarding short rows. Give this macro a try
for them...

Sub RemoveShortRows()
Dim X As Long
For X = Rows.Count To 1 Step -1
If Rows(X).RowHeight < 12.75 Then Rows(X).Delete
Next
End Sub

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
Give this code a try (substitute the width you want to compare to for the
8.43 width I used)...

Sub RemoveNarrowColumns()
Dim X As Long
For X = Columns.Count To 1 Step -1
If Columns(X).ColumnWidth < 8.43 Then Columns(X).Delete
Next
End Sub

Rick


"SteveDB1" wrote in message
...
Hi all.
I've recorded a macro, and in part of it I want to look at a specific
group
of columns' widths.
I.e., I want to know if a column is less than a standard, or
predetermined
width, and if so, delete that column. Someone has placed a series of
"buffer"
columns to act as spacers, and they're unnecessary for our purposes, so I
want to delete them, and doing this by hand is really time consuming.
I've read some of the posts, and I'm wondering if the following will
work.

dim MyCol as range

if MyCol.columnwidth<X 'where X is my choice of width.

myCol.select

Selection.Delete Shift:=xlToLeft

end if

Similarly, I want to do something identical with row heights.
would
dim MyRow as range

if MyRow.rowheight < Y 'where Y is my predetermined height value

MyRow.select
Selection.Delete Shift:=xlUp
end if


Thanks for your responses.
Best.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default column width and row height formatting, & IF

Rick,
Perfect, on both accounts....
Thank you.
Best.

"Rick Rothstein (MVP - VB)" wrote:

Sorry, missed your 2nd question regarding short rows. Give this macro a try
for them...

Sub RemoveShortRows()
Dim X As Long
For X = Rows.Count To 1 Step -1
If Rows(X).RowHeight < 12.75 Then Rows(X).Delete
Next
End Sub

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
Give this code a try (substitute the width you want to compare to for the
8.43 width I used)...

Sub RemoveNarrowColumns()
Dim X As Long
For X = Columns.Count To 1 Step -1
If Columns(X).ColumnWidth < 8.43 Then Columns(X).Delete
Next
End Sub

Rick


"SteveDB1" wrote in message
...
Hi all.
I've recorded a macro, and in part of it I want to look at a specific
group
of columns' widths.
I.e., I want to know if a column is less than a standard, or
predetermined
width, and if so, delete that column. Someone has placed a series of
"buffer"
columns to act as spacers, and they're unnecessary for our purposes, so I
want to delete them, and doing this by hand is really time consuming.
I've read some of the posts, and I'm wondering if the following will
work.

dim MyCol as range

if MyCol.columnwidth<X 'where X is my choice of width.

myCol.select

Selection.Delete Shift:=xlToLeft

end if

Similarly, I want to do something identical with row heights.
would
dim MyRow as range

if MyRow.rowheight < Y 'where Y is my predetermined height value

MyRow.select
Selection.Delete Shift:=xlUp
end if


Thanks for your responses.
Best.




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
Row Height or Column Width not Showing Brian Excel Worksheet Functions 1 March 19th 10 08:18 PM
Row height/column width Connie Martin Excel Discussion (Misc queries) 3 June 20th 09 04:12 PM
Column Width and Row Height Workbook Excel Worksheet Functions 4 March 30th 09 06:46 AM
Row height & Column width locked? Stephen C Excel Programming 1 August 15th 07 12:51 PM
Column Width and Row Height Pillow Excel Worksheet Functions 0 December 13th 05 03:58 PM


All times are GMT +1. The time now is 07:34 PM.

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"