PC Review


Reply
Thread Tools Rate Thread

Deleteing cells

 
 
=?Utf-8?B?TG9vcGluZyB0aHJvdWdo?=
Guest
Posts: n/a
 
      19th Nov 2007
Can someone help. this is what I have so far...

Sub deleting_cells()

Columns("A:A").Select
Selection.Find(What:="Quantity", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(4, 0).Select
ActiveCell.Offset.End(xlToRight).Select
ActiveCell.Offset(0, -6).Range("A1").Select

' From this point I want to delete every cell to the left of this active
cell minus 1 (essentially the cell in column A) I have read through dozens of
posts, but can't seam to figure it out.
After deleteing these cells, I want to drop down to the next row, move to
the last to the right and continue deleting info as needed via a loop.

this is probably very easy, but I am new to the whole vba world.

Thanks
Peter


 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      19th Nov 2007
I'm lost. In simple language can you explain what it is you want. I am
guessing here but are you looking to find all instances of "quantity" in
Column A and then delete some of the info from those lines??? Guessing again
but did you want to delete all of the cells except the right most cell??? Did
you want to leave the word quantity or did you want to get rid of that also???
--
HTH...

Jim Thomlinson


"Looping through" wrote:

> Can someone help. this is what I have so far...
>
> Sub deleting_cells()
>
> Columns("A:A").Select
> Selection.Find(What:="Quantity", After:=ActiveCell, LookIn:=xlFormulas, _
> LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
> MatchCase:=False, SearchFormat:=False).Activate
> ActiveCell.Offset(4, 0).Select
> ActiveCell.Offset.End(xlToRight).Select
> ActiveCell.Offset(0, -6).Range("A1").Select
>
> ' From this point I want to delete every cell to the left of this active
> cell minus 1 (essentially the cell in column A) I have read through dozens of
> posts, but can't seam to figure it out.
> After deleteing these cells, I want to drop down to the next row, move to
> the last to the right and continue deleting info as needed via a loop.
>
> this is probably very easy, but I am new to the whole vba world.
>
> Thanks
> Peter
>
>

 
Reply With Quote
 
=?Utf-8?B?TG9vcGluZyB0aHJvdWdo?=
Guest
Posts: n/a
 
      19th Nov 2007
Sorry for the confusion Jim,

Finding Quantity is just my starting point. There is information above that
point I want to keep. I offset 4 cells down and all the way to the right,
Because the information I want to keep is always located in cell "A?" and in
the last 6 cells of any row under Quantity. The info I want to delect can be
a range of 3 to 23 cells long. Hence the reason I find the end of the data
row and offset back 6 cells to select my true starting point to loop through
and delete unwanted cells.

Does that help?

"Jim Thomlinson" wrote:

> I'm lost. In simple language can you explain what it is you want. I am
> guessing here but are you looking to find all instances of "quantity" in
> Column A and then delete some of the info from those lines??? Guessing again
> but did you want to delete all of the cells except the right most cell??? Did
> you want to leave the word quantity or did you want to get rid of that also???
> --
> HTH...
>
> Jim Thomlinson
>
>
> "Looping through" wrote:
>
> > Can someone help. this is what I have so far...
> >
> > Sub deleting_cells()
> >
> > Columns("A:A").Select
> > Selection.Find(What:="Quantity", After:=ActiveCell, LookIn:=xlFormulas, _
> > LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
> > MatchCase:=False, SearchFormat:=False).Activate
> > ActiveCell.Offset(4, 0).Select
> > ActiveCell.Offset.End(xlToRight).Select
> > ActiveCell.Offset(0, -6).Range("A1").Select
> >
> > ' From this point I want to delete every cell to the left of this active
> > cell minus 1 (essentially the cell in column A) I have read through dozens of
> > posts, but can't seam to figure it out.
> > After deleteing these cells, I want to drop down to the next row, move to
> > the last to the right and continue deleting info as needed via a loop.
> >
> > this is probably very easy, but I am new to the whole vba world.
> >
> > Thanks
> > Peter
> >
> >

 
Reply With Quote
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      19th Nov 2007
So if I find Quantity in Cell A10 then I go down 4 rows to A14. The last
populated cell in row 14 is in column K for example so K14. You want to
delete cells A14 through E14. Once that is done then go down to the next row
and evealute that row (15). If the last populted cell in row 15 is J15 then
delete A1515. How long does this process continue. Assuming I have it
right...
--
HTH...

Jim Thomlinson


"Looping through" wrote:

> Sorry for the confusion Jim,
>
> Finding Quantity is just my starting point. There is information above that
> point I want to keep. I offset 4 cells down and all the way to the right,
> Because the information I want to keep is always located in cell "A?" and in
> the last 6 cells of any row under Quantity. The info I want to delect can be
> a range of 3 to 23 cells long. Hence the reason I find the end of the data
> row and offset back 6 cells to select my true starting point to loop through
> and delete unwanted cells.
>
> Does that help?
>
> "Jim Thomlinson" wrote:
>
> > I'm lost. In simple language can you explain what it is you want. I am
> > guessing here but are you looking to find all instances of "quantity" in
> > Column A and then delete some of the info from those lines??? Guessing again
> > but did you want to delete all of the cells except the right most cell??? Did
> > you want to leave the word quantity or did you want to get rid of that also???
> > --
> > HTH...
> >
> > Jim Thomlinson
> >
> >
> > "Looping through" wrote:
> >
> > > Can someone help. this is what I have so far...
> > >
> > > Sub deleting_cells()
> > >
> > > Columns("A:A").Select
> > > Selection.Find(What:="Quantity", After:=ActiveCell, LookIn:=xlFormulas, _
> > > LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
> > > MatchCase:=False, SearchFormat:=False).Activate
> > > ActiveCell.Offset(4, 0).Select
> > > ActiveCell.Offset.End(xlToRight).Select
> > > ActiveCell.Offset(0, -6).Range("A1").Select
> > >
> > > ' From this point I want to delete every cell to the left of this active
> > > cell minus 1 (essentially the cell in column A) I have read through dozens of
> > > posts, but can't seam to figure it out.
> > > After deleteing these cells, I want to drop down to the next row, move to
> > > the last to the right and continue deleting info as needed via a loop.
> > >
> > > this is probably very easy, but I am new to the whole vba world.
> > >
> > > Thanks
> > > Peter
> > >
> > >

 
Reply With Quote
 
=?Utf-8?B?TG9vcGluZyB0aHJvdWdo?=
Guest
Posts: n/a
 
      19th Nov 2007
This is correct. except please keep the data in cell A. this should continue
until no data is found in a row.

Thanks
Peter

"Jim Thomlinson" wrote:

> So if I find Quantity in Cell A10 then I go down 4 rows to A14. The last
> populated cell in row 14 is in column K for example so K14. You want to
> delete cells A14 through E14. Once that is done then go down to the next row
> and evealute that row (15). If the last populted cell in row 15 is J15 then
> delete A1515. How long does this process continue. Assuming I have it
> right...
> --
> HTH...
>
> Jim Thomlinson
>
>
> "Looping through" wrote:
>
> > Sorry for the confusion Jim,
> >
> > Finding Quantity is just my starting point. There is information above that
> > point I want to keep. I offset 4 cells down and all the way to the right,
> > Because the information I want to keep is always located in cell "A?" and in
> > the last 6 cells of any row under Quantity. The info I want to delect can be
> > a range of 3 to 23 cells long. Hence the reason I find the end of the data
> > row and offset back 6 cells to select my true starting point to loop through
> > and delete unwanted cells.
> >
> > Does that help?
> >
> > "Jim Thomlinson" wrote:
> >
> > > I'm lost. In simple language can you explain what it is you want. I am
> > > guessing here but are you looking to find all instances of "quantity" in
> > > Column A and then delete some of the info from those lines??? Guessing again
> > > but did you want to delete all of the cells except the right most cell??? Did
> > > you want to leave the word quantity or did you want to get rid of that also???
> > > --
> > > HTH...
> > >
> > > Jim Thomlinson
> > >
> > >
> > > "Looping through" wrote:
> > >
> > > > Can someone help. this is what I have so far...
> > > >
> > > > Sub deleting_cells()
> > > >
> > > > Columns("A:A").Select
> > > > Selection.Find(What:="Quantity", After:=ActiveCell, LookIn:=xlFormulas, _
> > > > LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
> > > > MatchCase:=False, SearchFormat:=False).Activate
> > > > ActiveCell.Offset(4, 0).Select
> > > > ActiveCell.Offset.End(xlToRight).Select
> > > > ActiveCell.Offset(0, -6).Range("A1").Select
> > > >
> > > > ' From this point I want to delete every cell to the left of this active
> > > > cell minus 1 (essentially the cell in column A) I have read through dozens of
> > > > posts, but can't seam to figure it out.
> > > > After deleteing these cells, I want to drop down to the next row, move to
> > > > the last to the right and continue deleting info as needed via a loop.
> > > >
> > > > this is probably very easy, but I am new to the whole vba world.
> > > >
> > > > Thanks
> > > > Peter
> > > >
> > > >

 
Reply With Quote
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      19th Nov 2007
Give this a whirl...

Sub DeleteStuff()
Dim rngFound As Range
Dim rngToSearch As Range
Dim rng As Range
Dim rngToDelete As Range

Set rngFound = Columns("A").Find(What:="Quantity", _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "Quantity was not found"
Else
Set rngToSearch = Range(rngFound.Offset(4, 0), _
rngFound.Offset(4, 0).End(xlDown))
For Each rng In rngToSearch
Set rngToDelete = Cells(rng.Row, Columns.Count).End(xlToLeft)
If rngToDelete.Column > 7 Then
Range(rng.Offset(0, 1), rngToDelete.Offset(0,
-6)).ClearContents
End If
Next rng
End If

End Sub

--
HTH...

Jim Thomlinson


"Looping through" wrote:

> This is correct. except please keep the data in cell A. this should continue
> until no data is found in a row.
>
> Thanks
> Peter
>
> "Jim Thomlinson" wrote:
>
> > So if I find Quantity in Cell A10 then I go down 4 rows to A14. The last
> > populated cell in row 14 is in column K for example so K14. You want to
> > delete cells A14 through E14. Once that is done then go down to the next row
> > and evealute that row (15). If the last populted cell in row 15 is J15 then
> > delete A1515. How long does this process continue. Assuming I have it
> > right...
> > --
> > HTH...
> >
> > Jim Thomlinson
> >
> >
> > "Looping through" wrote:
> >
> > > Sorry for the confusion Jim,
> > >
> > > Finding Quantity is just my starting point. There is information above that
> > > point I want to keep. I offset 4 cells down and all the way to the right,
> > > Because the information I want to keep is always located in cell "A?" and in
> > > the last 6 cells of any row under Quantity. The info I want to delect can be
> > > a range of 3 to 23 cells long. Hence the reason I find the end of the data
> > > row and offset back 6 cells to select my true starting point to loop through
> > > and delete unwanted cells.
> > >
> > > Does that help?
> > >
> > > "Jim Thomlinson" wrote:
> > >
> > > > I'm lost. In simple language can you explain what it is you want. I am
> > > > guessing here but are you looking to find all instances of "quantity" in
> > > > Column A and then delete some of the info from those lines??? Guessing again
> > > > but did you want to delete all of the cells except the right most cell??? Did
> > > > you want to leave the word quantity or did you want to get rid of that also???
> > > > --
> > > > HTH...
> > > >
> > > > Jim Thomlinson
> > > >
> > > >
> > > > "Looping through" wrote:
> > > >
> > > > > Can someone help. this is what I have so far...
> > > > >
> > > > > Sub deleting_cells()
> > > > >
> > > > > Columns("A:A").Select
> > > > > Selection.Find(What:="Quantity", After:=ActiveCell, LookIn:=xlFormulas, _
> > > > > LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
> > > > > MatchCase:=False, SearchFormat:=False).Activate
> > > > > ActiveCell.Offset(4, 0).Select
> > > > > ActiveCell.Offset.End(xlToRight).Select
> > > > > ActiveCell.Offset(0, -6).Range("A1").Select
> > > > >
> > > > > ' From this point I want to delete every cell to the left of this active
> > > > > cell minus 1 (essentially the cell in column A) I have read through dozens of
> > > > > posts, but can't seam to figure it out.
> > > > > After deleteing these cells, I want to drop down to the next row, move to
> > > > > the last to the right and continue deleting info as needed via a loop.
> > > > >
> > > > > this is probably very easy, but I am new to the whole vba world.
> > > > >
> > > > > Thanks
> > > > > Peter
> > > > >
> > > > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleteing Sian Windows Vista Mail 4 26th Aug 2009 08:30 PM
Deleteing koba Microsoft Excel Misc 2 25th Nov 2005 04:11 AM
Deleteing cells in Excel =?Utf-8?B?Z29ib25uaWVnbw==?= Microsoft Excel Misc 7 26th Jul 2005 05:21 PM
Deleteing specific cells in a record =?Utf-8?B?QWFyb24=?= Microsoft Access 1 24th Jan 2004 05:52 PM
Deleteing blank or "zero" cells Alain Dekker Microsoft Excel Misc 2 3rd Oct 2003 02:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:52 PM.