delete command?

vibehappy

New Member
Joined
Oct 11, 2006
Messages
5
is there a command to delete rows, or better yet, a range of rows? for example, is there a way to say IF(WEEKNUM(TODAY())>A3, delete A3:H8)? And by that (and I know that's written incorrectly), I mean to say if the week number in A3 is less (older) than today's week number, delete this range of cells...

thanks!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

xapie128

Board Regular
Joined
Aug 26, 2006
Messages
82
If you are talking about VBA code...
This is how to delete rows:
Code:
    Columns("A:H").Select
    Selection.Delete Shift:=xlToLeft
But at one point, you asked:
for example, is there a way to say IF(WEEKNUM(TODAY())>A3, delete A3:H8)
Note that A3:H8 is a Range of cells, not full columns.
If you just want to clear what's in that range, then use:
Code:
    Range("A3:H8").Select
    Selection.ClearContents
 

vibehappy

New Member
Joined
Oct 11, 2006
Messages
5
hey, thanks for the reply! well, what i'm looking to do is delete rows, rather than clear the contents.

could i then do this?

Rows("3:8").Select
Selection.Delete Shift:=xlUp

would that be the correct code?

thanks again for the reply, i appreciate it. :)
have a great day!
 

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
hey, thanks for the reply! well, what i'm looking to do is delete rows, rather than clear the contents.

could i then do this?

Rows("3:8").Select
Selection.Delete Shift:=xlUp

would that be the correct code?

thanks again for the reply, i appreciate it. :)
have a great day!
Hi, vibehappy
Welcome to the Board !!!!!

if you want to delete the entire rows, then that would work indeed: but why not try out before asking ?
you don't need to select the range
Code:
Rows("3:8").Delete
(shift up is the default)

kind regards,
Erik
 

vibehappy

New Member
Joined
Oct 11, 2006
Messages
5

ADVERTISEMENT

thanks very much for the reply...that should help a bunch! and i'll try it out next time for sure...sorry i didn't think of that, lol. have a great day!
 

Forum statistics

Threads
1,136,926
Messages
5,678,605
Members
419,775
Latest member
joh93

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top