PC Review


Reply
Thread Tools Rate Thread

Delete Rows and Sheets

 
 
Sal
Guest
Posts: n/a
 
      12th May 2009
Is there a better way to delete row 1 in Sheet1 than this

Sheets("Sheet1").Select
Rows("1:1").Select
Selection.Delete Shift:=xlUp
Range("A1").Select

Is there a better way to delete Column B in Sheet1 than this?

Sheets("Sheet1").Select
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft

Is there a better way using Sheet1, to Cut Column D and paste the cut cells
in front of Column A than this?
Sheets("Sheet1").Select
Columns("D").Select
Selection.Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight

 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      12th May 2009
When you record a macro ;each single action is recorded....the below code
does the same 3 actions///

Sheets("Sheet1").Rows(1).Delete
Sheets("Sheet1").Columns(1).Delete
Columns("A:A").Insert Shift:=xlToRight



If this post helps click Yes
---------------
Jacob Skaria


"Sal" wrote:

> Is there a better way to delete row 1 in Sheet1 than this
>
> Sheets("Sheet1").Select
> Rows("1:1").Select
> Selection.Delete Shift:=xlUp
> Range("A1").Select
>
> Is there a better way to delete Column B in Sheet1 than this?
>
> Sheets("Sheet1").Select
> Columns("B:B").Select
> Selection.Delete Shift:=xlToLeft
>
> Is there a better way using Sheet1, to Cut Column D and paste the cut cells
> in front of Column A than this?
> Sheets("Sheet1").Select
> Columns("D").Select
> Selection.Cut
> Columns("A:A").Select
> Selection.Insert Shift:=xlToRight
>

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      12th May 2009
You can avoid the Workbook and sheetname..

With ActiveWorkbook.Sheets("Sheet1")
..Rows(1).Delete
..Columns(1).Delete
..Columns("D").Cut
..Columns("A:A").Insert Shift:=xlToRight
End With

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

> When you record a macro ;each single action is recorded....the below code
> does the same 3 actions///
>
> Sheets("Sheet1").Rows(1).Delete
> Sheets("Sheet1").Columns(1).Delete
> Columns("A:A").Insert Shift:=xlToRight
>
>
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Sal" wrote:
>
> > Is there a better way to delete row 1 in Sheet1 than this
> >
> > Sheets("Sheet1").Select
> > Rows("1:1").Select
> > Selection.Delete Shift:=xlUp
> > Range("A1").Select
> >
> > Is there a better way to delete Column B in Sheet1 than this?
> >
> > Sheets("Sheet1").Select
> > Columns("B:B").Select
> > Selection.Delete Shift:=xlToLeft
> >
> > Is there a better way using Sheet1, to Cut Column D and paste the cut cells
> > in front of Column A than this?
> > Sheets("Sheet1").Select
> > Columns("D").Select
> > Selection.Cut
> > Columns("A:A").Select
> > Selection.Insert Shift:=xlToRight
> >

 
Reply With Quote
 
Sal
Guest
Posts: n/a
 
      13th May 2009
Perfect! Thank you

"Jacob Skaria" wrote:

> When you record a macro ;each single action is recorded....the below code
> does the same 3 actions///
>
> Sheets("Sheet1").Rows(1).Delete
> Sheets("Sheet1").Columns(1).Delete
> Columns("A:A").Insert Shift:=xlToRight
>
>
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Sal" wrote:
>
> > Is there a better way to delete row 1 in Sheet1 than this
> >
> > Sheets("Sheet1").Select
> > Rows("1:1").Select
> > Selection.Delete Shift:=xlUp
> > Range("A1").Select
> >
> > Is there a better way to delete Column B in Sheet1 than this?
> >
> > Sheets("Sheet1").Select
> > Columns("B:B").Select
> > Selection.Delete Shift:=xlToLeft
> >
> > Is there a better way using Sheet1, to Cut Column D and paste the cut cells
> > in front of Column A than this?
> > Sheets("Sheet1").Select
> > Columns("D").Select
> > Selection.Cut
> > Columns("A:A").Select
> > Selection.Insert Shift:=xlToRight
> >

 
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
Delete Excel rows/sheets Rob Oldfield Microsoft Dot NET Framework Forms 5 12th Oct 2010 01:25 PM
Delete rows of data in multiple sheets Yossy Microsoft Excel Programming 13 26th Oct 2008 02:46 PM
Delete rows in multiple sheets without loop? MTT727 Microsoft Excel Programming 2 26th Jul 2005 03:07 PM
How can I delete similar rows in excel workbook with many sheets? =?Utf-8?B?SlNjaHJhZGVy?= Microsoft Excel Worksheet Functions 1 26th Apr 2005 06:40 PM
Delete Rows from multiple Sheets. =?Utf-8?B?ZHJib2JzbGVk?= Microsoft Excel Programming 3 7th Apr 2005 01:23 AM


Features
 

Advertising
 

Newsgroups
 


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