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

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
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
 
Upvote 0
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!
 
Upvote 0
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
 
Upvote 0
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!
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,844
Members
449,051
Latest member
excelquestion515

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
Back
Top