ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Rows based on # of rows (no variable?) (https://www.excelbanter.com/excel-programming/419269-delete-rows-based-rows-no-variable.html)

DanaK

Delete Rows based on # of rows (no variable?)
 
SO frustrated. I'm a very light-weight VBA user. I have a document where I
need to delete several rows at a time, shifting up. Always three rows. I
tried recording this, but it doesn't work that way. I've dug around in Help
until I'm utterly confused as to where to start. I have a workbook with the
steps (what I was given to follow) but I only really need to know about
deleting rows. I think I might be able to figure out the rest. I'll need to
run this same sequence of steps multiple times, but I can figure that out as
well. Thanks to anyone who can help!--
DanaK

DMoney

Delete Rows based on # of rows (no variable?)
 
This should give u what u need.


Sub tst()
Dim a As String
Dim b As String
Dim c As Integer
Dim d As String
c = 2
Range("a1").Select
Do Until ActiveCell.Value = "done"
If ActiveCell.Value = "x" Then
a = ActiveCell.Address
b = ActiveCell.Offset(c, 0).Address
d = a & ":" & b
Range(d).Select
Selection.EntireRow.Delete
End If
ActiveCell.Offset(1, 0).Activate
Loop
End Sub


"DanaK" wrote:

SO frustrated. I'm a very light-weight VBA user. I have a document where I
need to delete several rows at a time, shifting up. Always three rows. I
tried recording this, but it doesn't work that way. I've dug around in Help
until I'm utterly confused as to where to start. I have a workbook with the
steps (what I was given to follow) but I only really need to know about
deleting rows. I think I might be able to figure out the rest. I'll need to
run this same sequence of steps multiple times, but I can figure that out as
well. Thanks to anyone who can help!--
DanaK


DanaK

Delete Rows based on # of rows (no variable?)
 
Thanks! I do have a question. Do I need to modify something? When I start it,
it runs all the way to the bottom & then I get an Application Defined or
Object error at line ActiveCell.Offset(1, 0).Activate. First row to delete
will be 8 & the last would be 24.
--
DanaK


"DanaK" wrote:

SO frustrated. I'm a very light-weight VBA user. I have a document where I
need to delete several rows at a time, shifting up. Always three rows. I
tried recording this, but it doesn't work that way. I've dug around in Help
until I'm utterly confused as to where to start. I have a workbook with the
steps (what I was given to follow) but I only really need to know about
deleting rows. I think I might be able to figure out the rest. I'll need to
run this same sequence of steps multiple times, but I can figure that out as
well. Thanks to anyone who can help!--
DanaK


DMoney

Delete Rows based on # of rows (no variable?)
 
I set the loop to end when the activecell is equal to "done" -- you can
either type the word done in column A at the bottom of your spreadsheet or
change the word done in the do statement to something that works for u.



"DanaK" wrote:

SO frustrated. I'm a very light-weight VBA user. I have a document where I
need to delete several rows at a time, shifting up. Always three rows. I
tried recording this, but it doesn't work that way. I've dug around in Help
until I'm utterly confused as to where to start. I have a workbook with the
steps (what I was given to follow) but I only really need to know about
deleting rows. I think I might be able to figure out the rest. I'll need to
run this same sequence of steps multiple times, but I can figure that out as
well. Thanks to anyone who can help!--
DanaK


DanaK

Delete Rows based on # of rows (no variable?)
 
I typed done to end the sheet & that stopped it from running to the bottom,
but it doesn't delete any rows. It just drops down to the cell with done. Is
there something else I'm not doing?
DanaK


"dmoney" wrote:

I set the loop to end when the activecell is equal to "done" -- you can
either type the word done in column A at the bottom of your spreadsheet or
change the word done in the do statement to something that works for u.



"DanaK" wrote:

SO frustrated. I'm a very light-weight VBA user. I have a document where I
need to delete several rows at a time, shifting up. Always three rows. I
tried recording this, but it doesn't work that way. I've dug around in Help
until I'm utterly confused as to where to start. I have a workbook with the
steps (what I was given to follow) but I only really need to know about
deleting rows. I think I might be able to figure out the rest. I'll need to
run this same sequence of steps multiple times, but I can figure that out as
well. Thanks to anyone who can help!--
DanaK


DMoney

Delete Rows based on # of rows (no variable?)
 
look in the code -- there is a line that defines what it is looking for to
delete. in this case, i put in an x -- you can change that to meet what you
need.


"DanaK" wrote:

I typed done to end the sheet & that stopped it from running to the bottom,
but it doesn't delete any rows. It just drops down to the cell with done. Is
there something else I'm not doing?
DanaK


"dmoney" wrote:

I set the loop to end when the activecell is equal to "done" -- you can
either type the word done in column A at the bottom of your spreadsheet or
change the word done in the do statement to something that works for u.



"DanaK" wrote:

SO frustrated. I'm a very light-weight VBA user. I have a document where I
need to delete several rows at a time, shifting up. Always three rows. I
tried recording this, but it doesn't work that way. I've dug around in Help
until I'm utterly confused as to where to start. I have a workbook with the
steps (what I was given to follow) but I only really need to know about
deleting rows. I think I might be able to figure out the rest. I'll need to
run this same sequence of steps multiple times, but I can figure that out as
well. Thanks to anyone who can help!--
DanaK


DMoney

Delete Rows based on # of rows (no variable?)
 

DanaK - Feel free to email me at and attach your file
and I will see if I can better understand what you are trying to accomplish.
I am sure that we can get it done.

regards,
dmoney

"DanaK" wrote:

I typed done to end the sheet & that stopped it from running to the bottom,
but it doesn't delete any rows. It just drops down to the cell with done. Is
there something else I'm not doing?
DanaK


"dmoney" wrote:

I set the loop to end when the activecell is equal to "done" -- you can
either type the word done in column A at the bottom of your spreadsheet or
change the word done in the do statement to something that works for u.



"DanaK" wrote:

SO frustrated. I'm a very light-weight VBA user. I have a document where I
need to delete several rows at a time, shifting up. Always three rows. I
tried recording this, but it doesn't work that way. I've dug around in Help
until I'm utterly confused as to where to start. I have a workbook with the
steps (what I was given to follow) but I only really need to know about
deleting rows. I think I might be able to figure out the rest. I'll need to
run this same sequence of steps multiple times, but I can figure that out as
well. Thanks to anyone who can help!--
DanaK


DanaK

Delete Rows based on # of rows (no variable?)
 
Sorry for the delay- had an out of town trip. I think I got it. It appears to
be doing what I needed it to. I really appreciate you being so patient! I
felt like 5 year old, what now? Why this? Hopefully more of this stuff will
sink in....Thank you!
--
DanaK


"dmoney" wrote:


DanaK - Feel free to email me at and attach your file
and I will see if I can better understand what you are trying to accomplish.
I am sure that we can get it done.

regards,
dmoney

"DanaK" wrote:

I typed done to end the sheet & that stopped it from running to the bottom,
but it doesn't delete any rows. It just drops down to the cell with done. Is
there something else I'm not doing?
DanaK


"dmoney" wrote:

I set the loop to end when the activecell is equal to "done" -- you can
either type the word done in column A at the bottom of your spreadsheet or
change the word done in the do statement to something that works for u.



"DanaK" wrote:

SO frustrated. I'm a very light-weight VBA user. I have a document where I
need to delete several rows at a time, shifting up. Always three rows. I
tried recording this, but it doesn't work that way. I've dug around in Help
until I'm utterly confused as to where to start. I have a workbook with the
steps (what I was given to follow) but I only really need to know about
deleting rows. I think I might be able to figure out the rest. I'll need to
run this same sequence of steps multiple times, but I can figure that out as
well. Thanks to anyone who can help!--
DanaK



All times are GMT +1. The time now is 01:29 PM.

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