Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Delete Rows below a certain cell

Hi! I have a question regarding macros in Excel. Can
you create a macro to go to a certain cell and then
delete that cell and the cells after that that contain
data?

For example:
I have a report that I have imported into Excel. On row
20, in Column "C", I have a heading called "**Report
Status**". I want the macro to go to that cell and
delete all the rows below it that contain data.

FYI...The heading is not always on row 20 in column "C".
The row varies each time I import data!

I appreciate any help that can be given!

Julie
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Delete Rows below a certain cell

Julie,

This worked in Excel97 [watch word wrap]

Dim x As Long, y As Long
'
x = Columns("C:C").Find(What:="report", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Row
y = Selection.SpecialCells(xlCellTypeLastCell).Row
Range(Rows(x), Rows(y)).EntireRow.Delete

If 'report' appears in any column, change
Columns("C:C").
to
Cells.
--
sb
"Julie" wrote in message
...
Hi! I have a question regarding macros in Excel. Can
you create a macro to go to a certain cell and then
delete that cell and the cells after that that contain
data?

For example:
I have a report that I have imported into Excel. On row
20, in Column "C", I have a heading called "**Report
Status**". I want the macro to go to that cell and
delete all the rows below it that contain data.

FYI...The heading is not always on row 20 in column "C".
The row varies each time I import data!

I appreciate any help that can be given!

Julie



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Delete Rows below a certain cell

Hi Steve,

For some reason, I am getting a mismatch error on this
example. I tried changing a couple of things and I still
got the same error. Any suggestions?

Thanks for your help!

Julie
-----Original Message-----
Julie,

This worked in Excel97 [watch word wrap]

Dim x As Long, y As Long
'
x = Columns("C:C").Find(What:="report",

After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,

SearchDirection:=xlNext, _
MatchCase:=False).Row
y = Selection.SpecialCells(xlCellTypeLastCell).Row
Range(Rows(x), Rows(y)).EntireRow.Delete

If 'report' appears in any column, change
Columns("C:C").
to
Cells.
--
sb
"Julie" wrote in

message
...
Hi! I have a question regarding macros in Excel. Can
you create a macro to go to a certain cell and then
delete that cell and the cells after that that contain
data?

For example:
I have a report that I have imported into Excel. On

row
20, in Column "C", I have a heading called "**Report
Status**". I want the macro to go to that cell and
delete all the rows below it that contain data.

FYI...The heading is not always on row 20 in

column "C".
The row varies each time I import data!

I appreciate any help that can be given!

Julie



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Delete Rows below a certain cell

Which line causes the error?
(as I said - it worked in Excel97)

Make sure that you correct word wrap...
Remove the comment lines and the blank lines...
Go to the Debug menu and select Compile to find
problem areas in the code. Repeat until no problems
are found.

Dim x as Long, y as Long

' Make these one line
x = Columns("C:C").Find(What:="report",
After:=ActiveCell,

LookIn:=xlFormulas, _

' Make these one line
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _

MatchCase:=False).Row
y = Selection.SpecialCells(xlCellTypeLastCell).Row
Range(Rows(x), Rows(y)).EntireRow.Delete

--
sb
wrote in message
...
Hi Steve,

For some reason, I am getting a mismatch error on this
example. I tried changing a couple of things and I still
got the same error. Any suggestions?

Thanks for your help!

Julie
-----Original Message-----
Julie,

This worked in Excel97 [watch word wrap]

Dim x As Long, y As Long
'
x = Columns("C:C").Find(What:="report",

After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,

SearchDirection:=xlNext, _
MatchCase:=False).Row
y = Selection.SpecialCells(xlCellTypeLastCell).Row
Range(Rows(x), Rows(y)).EntireRow.Delete

If 'report' appears in any column, change
Columns("C:C").
to
Cells.
--
sb
"Julie" wrote in

message
...
Hi! I have a question regarding macros in Excel. Can
you create a macro to go to a certain cell and then
delete that cell and the cells after that that contain
data?

For example:
I have a report that I have imported into Excel. On

row
20, in Column "C", I have a heading called "**Report
Status**". I want the macro to go to that cell and
delete all the rows below it that contain data.

FYI...The heading is not always on row 20 in

column "C".
The row varies each time I import data!

I appreciate any help that can be given!

Julie



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Delete Rows below a certain cell

Hi Steve,

This is exactly what I have:

Dim x As Long, y As Long

x = Columns("C:C").Find(What:="*REPORTS TO INCLUDE*",
After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:=False).Row
y = Selection.SpecialCells(xlCellTypeLastCell).Row
Range(Rows(x), Rows(y)).EntireRow.Delete

The second line of x is actually on the first row. My
mismatch error is showing within the x portion with the
arrow on the second row. I tried making a minor
adjustment to my Find(What:=....), thinking that was the
problem, but it wasn't. Like you said, it could be that
this may only work I Office 97. I appreciate all of your
help and have a great day!

Julie
-----Original Message-----
Which line causes the error?
(as I said - it worked in Excel97)

Make sure that you correct word wrap...
Remove the comment lines and the blank lines...
Go to the Debug menu and select Compile to find
problem areas in the code. Repeat until no problems
are found.

Dim x as Long, y as Long

' Make these one line
x = Columns("C:C").Find(What:="report",
After:=ActiveCell,

LookIn:=xlFormulas, _

' Make these one line
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _

MatchCase:=False).Row
y = Selection.SpecialCells(xlCellTypeLastCell).Row
Range(Rows(x), Rows(y)).EntireRow.Delete

--
sb
wrote in message
...
Hi Steve,

For some reason, I am getting a mismatch error on this
example. I tried changing a couple of things and I

still
got the same error. Any suggestions?

Thanks for your help!

Julie
-----Original Message-----
Julie,

This worked in Excel97 [watch word wrap]

Dim x As Long, y As Long
'
x = Columns("C:C").Find(What:="report",

After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,

SearchDirection:=xlNext, _
MatchCase:=False).Row
y = Selection.SpecialCells(xlCellTypeLastCell).Row
Range(Rows(x), Rows(y)).EntireRow.Delete

If 'report' appears in any column, change
Columns("C:C").
to
Cells.
--
sb
"Julie" wrote in

message
...
Hi! I have a question regarding macros in Excel.

Can
you create a macro to go to a certain cell and then
delete that cell and the cells after that that

contain
data?

For example:
I have a report that I have imported into Excel. On

row
20, in Column "C", I have a heading called "**Report
Status**". I want the macro to go to that cell and
delete all the rows below it that contain data.

FYI...The heading is not always on row 20 in

column "C".
The row varies each time I import data!

I appreciate any help that can be given!

Julie


.



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Delete Rows below a certain cell

Julie,

Aha! You are missing a line continuation (probably my fault)
This should all be one line

After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:=False).Row


change to:
After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False).Row

note the underscore '_'

Also - you can use the single word report (in lower case) to find...

--
sb
"Julie" wrote in message
...
Hi Steve,

This is exactly what I have:

Dim x As Long, y As Long

x = Columns("C:C").Find(What:="*REPORTS TO INCLUDE*",
After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:=False).Row
y = Selection.SpecialCells(xlCellTypeLastCell).Row
Range(Rows(x), Rows(y)).EntireRow.Delete

The second line of x is actually on the first row. My
mismatch error is showing within the x portion with the
arrow on the second row. I tried making a minor
adjustment to my Find(What:=....), thinking that was the
problem, but it wasn't. Like you said, it could be that
this may only work I Office 97. I appreciate all of your
help and have a great day!

Julie
-----Original Message-----
Which line causes the error?
(as I said - it worked in Excel97)

Make sure that you correct word wrap...
Remove the comment lines and the blank lines...
Go to the Debug menu and select Compile to find
problem areas in the code. Repeat until no problems
are found.

Dim x as Long, y as Long

' Make these one line
x = Columns("C:C").Find(What:="report",
After:=ActiveCell,

LookIn:=xlFormulas, _

' Make these one line
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _

MatchCase:=False).Row
y = Selection.SpecialCells(xlCellTypeLastCell).Row
Range(Rows(x), Rows(y)).EntireRow.Delete

--
sb
wrote in message
...
Hi Steve,

For some reason, I am getting a mismatch error on this
example. I tried changing a couple of things and I

still
got the same error. Any suggestions?

Thanks for your help!

Julie
-----Original Message-----
Julie,

This worked in Excel97 [watch word wrap]

Dim x As Long, y As Long
'
x = Columns("C:C").Find(What:="report",
After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False).Row
y = Selection.SpecialCells(xlCellTypeLastCell).Row
Range(Rows(x), Rows(y)).EntireRow.Delete

If 'report' appears in any column, change
Columns("C:C").
to
Cells.
--
sb
"Julie" wrote in
message
...
Hi! I have a question regarding macros in Excel.

Can
you create a macro to go to a certain cell and then
delete that cell and the cells after that that

contain
data?

For example:
I have a report that I have imported into Excel. On
row
20, in Column "C", I have a heading called "**Report
Status**". I want the macro to go to that cell and
delete all the rows below it that contain data.

FYI...The heading is not always on row 20 in
column "C".
The row varies each time I import data!

I appreciate any help that can be given!

Julie


.



.



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
Delete rows on Cell wal50 Excel Discussion (Misc queries) 3 December 31st 07 12:52 PM
To delete rows when more than one cell is blank [email protected] Excel Worksheet Functions 4 September 27th 06 10:49 PM
Delete empty rows with cell type 2 FrankNL Excel Discussion (Misc queries) 1 May 3rd 06 11:10 AM
delete rows if dublicate cell value in column 2 gus Excel Programming 1 September 19th 03 03:45 PM
Delete Rows with letter #VALUE in cell J Steven R. Berke Excel Programming 0 July 9th 03 10:37 PM


All times are GMT +1. The time now is 11:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"