ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple macro help (https://www.excelbanter.com/excel-programming/324643-simple-macro-help.html)

lars

Simple macro help
 
Hello,

I have a simple macro problem, which is driving me crazy. I built a
marco to open a daily text file in excel. Once the report is open I do
a Find text, once it finds the text I want it to delete 7 rows up and
then 2 rows down. The only problem I have is that I do not want the
formula to use cell reference like the one below has. Reason is that
the rows I want deleted change for one day to the other. Below is a
example from my macro.

Cells.FindNext(After:=ActiveCell).Activate
Rows("164:170").Select
Range("A170").Activate
Selection.Delete Shift:=xlUp
Rows("164:165").Select
Selection.Delete Shift:=xlUp
Columns("A:A").Select

Thank you very much, any help will be great.

Lars


Bob Phillips[_6_]

Simple macro help
 
Something like

Set foundCell = Cells.FindNext(After:=ActiveCell)
If Not foundCell Is Nothing Then
foundCell.Offset(-7,0).Resize(9,1).Entirerow.Delete
End If

--

HTH

RP
(remove nothere from the email address if mailing direct)


"lars" wrote in message
oups.com...
Hello,

I have a simple macro problem, which is driving me crazy. I built a
marco to open a daily text file in excel. Once the report is open I do
a Find text, once it finds the text I want it to delete 7 rows up and
then 2 rows down. The only problem I have is that I do not want the
formula to use cell reference like the one below has. Reason is that
the rows I want deleted change for one day to the other. Below is a
example from my macro.

Cells.FindNext(After:=ActiveCell).Activate
Rows("164:170").Select
Range("A170").Activate
Selection.Delete Shift:=xlUp
Rows("164:165").Select
Selection.Delete Shift:=xlUp
Columns("A:A").Select

Thank you very much, any help will be great.

Lars





All times are GMT +1. The time now is 03:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com