PC Review


Reply
Thread Tools Rate Thread

column width and row height formatting, & IF

 
 
SteveDB1
Guest
Posts: n/a
 
      5th Jun 2008
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 With Quote
 
 
 
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      5th Jun 2008
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" <(E-Mail Removed)> wrote in message
news:13C3DDED-FCF9-468B-B99E-(E-Mail Removed)...
> 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 With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      5th Jun 2008
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)" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:13C3DDED-FCF9-468B-B99E-(E-Mail Removed)...
>> 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 With Quote
 
SteveDB1
Guest
Posts: n/a
 
      5th Jun 2008
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)" <(E-Mail Removed)> wrote in
> message news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:13C3DDED-FCF9-468B-B99E-(E-Mail Removed)...
> >> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Row height/column width =?Utf-8?B?Q29ubmllIE1hcnRpbg==?= Microsoft Excel Misc 3 20th Jun 2009 04:12 PM
Column Width and Row Height Workbook Microsoft Excel Worksheet Functions 4 30th Mar 2009 06:46 AM
Changing Row Height/Column Width DJ Microsoft Excel Misc 4 27th Feb 2009 02:07 AM
Column Width and Row Height =?Utf-8?B?UGlsbG93?= Microsoft Excel Worksheet Functions 0 13th Dec 2005 03:58 PM
Re: fixing the column width and row height Dave Peterson Microsoft Excel Misc 1 8th Oct 2003 01:45 PM


Features
 

Advertising
 

Newsgroups
 


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