Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Search and Move - Cannot Figure This Out - Please Help

My spreadsheet has 4 columns, for example:

Col A B C D
Description Type Charge Offering
Alert $35 SO
Alert SO
Alert 9113 SO
Perform $ 5 SO
Perform $12 SO
Perform 9220 SO
Alert $19 SCO
Alert 8332 SCO
AA i/p $23 SO
AA i/p SO

I need to:
1) Go through each row of Col D; if it says 'SCO', then go to next row of
Col D.
2) If it says 'SO', then
a) If Col C 0, add the value in Col C to any other value in Col C
(going down)
until both Col A and Col B are < blank, and put that sum in Col C
on the
same row where both Col A and Col B are < blank, then erase the
individual entries in Col C used to come to that sum.
If during this process you ever find that both Col A and B are
blank, then
stop and go to the next row in Col D, and start over to see if it
says 'SO'
or 'SCO'.
b) If Col C is blank or = 0, then go to the next row of Col D and
start over to
see if it says 'SO' or 'SCO'.

I've struggled with this for quite some time and am desperately hoping
someone can help. The final product, using the example above and afer the
macro has run, should look like this:

Col A B C D
Description Type Charge Offering
Alert SO
Alert SO
Alert 9113 $35 SO
Perform SO
Perform SO
Perform 9220 $17 SO
Alert $19 SCO
Alert 8332 SCO
AA i/p $23 SO
AA i/p SO
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Search and Move - Cannot Figure This Out - Please Help

Paige
The following macro will do what you want. I think. Try it and post
back if I misread what you wrote. HTH Otto
Option Explicit
Dim First As Range
Dim Last As Range
Dim c As Long
Dim d As Long
Sub Whatever()
c = 2
Do
If Cells(c, 4).Value = "SCO" Then
c = c + 1
GoTo NextCell
End If
If IsEmpty(Cells(c, 3).Value) Or _
Cells(c, 3).Value = 0 Then
c = c + 1
GoTo NextCell
End If
If Cells(c, 3).Value 0 Then _
Set First = Cells(c, 3)
For d = 1 To 50
If Not IsEmpty(Cells(c, 1).Offset(d).Value) And _
Not IsEmpty(Cells(c, 2).Offset(d).Value) Then
Set Last = Cells(c, 3).Offset(d - 1)
c = c + d + 1
Exit For
End If
If d = 20 Then Exit Sub
Next d
If Not First Is Nothing And _
Not Last Is Nothing Then
Last.Offset(1).Value = Application.Sum(Range(First, Last))
Range(First, Last).ClearContents
End If
Set First = Nothing
Set Last = Nothing
NextCell:
Loop Until Cells(c, 1).Row Cells(Rows.Count, 1).End(xlUp).Row
End Sub

"Paige" wrote in message
...
My spreadsheet has 4 columns, for example:

Col A B C D
Description Type Charge Offering
Alert $35 SO
Alert SO
Alert 9113 SO
Perform $ 5 SO
Perform $12 SO
Perform 9220 SO
Alert $19 SCO
Alert 8332 SCO
AA i/p $23 SO
AA i/p SO

I need to:
1) Go through each row of Col D; if it says 'SCO', then go to next row of
Col D.
2) If it says 'SO', then
a) If Col C 0, add the value in Col C to any other value in Col C
(going down)
until both Col A and Col B are < blank, and put that sum in Col C
on the
same row where both Col A and Col B are < blank, then erase the
individual entries in Col C used to come to that sum.
If during this process you ever find that both Col A and B are
blank, then
stop and go to the next row in Col D, and start over to see if it
says 'SO'
or 'SCO'.
b) If Col C is blank or = 0, then go to the next row of Col D and
start over to
see if it says 'SO' or 'SCO'.

I've struggled with this for quite some time and am desperately hoping
someone can help. The final product, using the example above and afer the
macro has run, should look like this:

Col A B C D
Description Type Charge Offering
Alert SO
Alert SO
Alert 9113 $35 SO
Perform SO
Perform SO
Perform 9220 $17 SO
Alert $19 SCO
Alert 8332 SCO
AA i/p $23 SO
AA i/p SO



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Search and Move - Cannot Figure This Out - Please Help

Thanks so much Otto. I am still working and have to get a report out
tonight; will test this first thing tomorrow am and let you know. I really
appreciate your help!

"Otto Moehrbach" wrote:

Paige
The following macro will do what you want. I think. Try it and post
back if I misread what you wrote. HTH Otto
Option Explicit
Dim First As Range
Dim Last As Range
Dim c As Long
Dim d As Long
Sub Whatever()
c = 2
Do
If Cells(c, 4).Value = "SCO" Then
c = c + 1
GoTo NextCell
End If
If IsEmpty(Cells(c, 3).Value) Or _
Cells(c, 3).Value = 0 Then
c = c + 1
GoTo NextCell
End If
If Cells(c, 3).Value 0 Then _
Set First = Cells(c, 3)
For d = 1 To 50
If Not IsEmpty(Cells(c, 1).Offset(d).Value) And _
Not IsEmpty(Cells(c, 2).Offset(d).Value) Then
Set Last = Cells(c, 3).Offset(d - 1)
c = c + d + 1
Exit For
End If
If d = 20 Then Exit Sub
Next d
If Not First Is Nothing And _
Not Last Is Nothing Then
Last.Offset(1).Value = Application.Sum(Range(First, Last))
Range(First, Last).ClearContents
End If
Set First = Nothing
Set Last = Nothing
NextCell:
Loop Until Cells(c, 1).Row Cells(Rows.Count, 1).End(xlUp).Row
End Sub

"Paige" wrote in message
...
My spreadsheet has 4 columns, for example:

Col A B C D
Description Type Charge Offering
Alert $35 SO
Alert SO
Alert 9113 SO
Perform $ 5 SO
Perform $12 SO
Perform 9220 SO
Alert $19 SCO
Alert 8332 SCO
AA i/p $23 SO
AA i/p SO

I need to:
1) Go through each row of Col D; if it says 'SCO', then go to next row of
Col D.
2) If it says 'SO', then
a) If Col C 0, add the value in Col C to any other value in Col C
(going down)
until both Col A and Col B are < blank, and put that sum in Col C
on the
same row where both Col A and Col B are < blank, then erase the
individual entries in Col C used to come to that sum.
If during this process you ever find that both Col A and B are
blank, then
stop and go to the next row in Col D, and start over to see if it
says 'SO'
or 'SCO'.
b) If Col C is blank or = 0, then go to the next row of Col D and
start over to
see if it says 'SO' or 'SCO'.

I've struggled with this for quite some time and am desperately hoping
someone can help. The final product, using the example above and afer the
macro has run, should look like this:

Col A B C D
Description Type Charge Offering
Alert SO
Alert SO
Alert 9113 $35 SO
Perform SO
Perform SO
Perform 9220 $17 SO
Alert $19 SCO
Alert 8332 SCO
AA i/p $23 SO
AA i/p SO




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Search and Move - Cannot Figure This Out - Please Help

Otto, works great - thank you SOOOOO....much.

"Otto Moehrbach" wrote:

Paige
The following macro will do what you want. I think. Try it and post
back if I misread what you wrote. HTH Otto
Option Explicit
Dim First As Range
Dim Last As Range
Dim c As Long
Dim d As Long
Sub Whatever()
c = 2
Do
If Cells(c, 4).Value = "SCO" Then
c = c + 1
GoTo NextCell
End If
If IsEmpty(Cells(c, 3).Value) Or _
Cells(c, 3).Value = 0 Then
c = c + 1
GoTo NextCell
End If
If Cells(c, 3).Value 0 Then _
Set First = Cells(c, 3)
For d = 1 To 50
If Not IsEmpty(Cells(c, 1).Offset(d).Value) And _
Not IsEmpty(Cells(c, 2).Offset(d).Value) Then
Set Last = Cells(c, 3).Offset(d - 1)
c = c + d + 1
Exit For
End If
If d = 20 Then Exit Sub
Next d
If Not First Is Nothing And _
Not Last Is Nothing Then
Last.Offset(1).Value = Application.Sum(Range(First, Last))
Range(First, Last).ClearContents
End If
Set First = Nothing
Set Last = Nothing
NextCell:
Loop Until Cells(c, 1).Row Cells(Rows.Count, 1).End(xlUp).Row
End Sub

"Paige" wrote in message
...
My spreadsheet has 4 columns, for example:

Col A B C D
Description Type Charge Offering
Alert $35 SO
Alert SO
Alert 9113 SO
Perform $ 5 SO
Perform $12 SO
Perform 9220 SO
Alert $19 SCO
Alert 8332 SCO
AA i/p $23 SO
AA i/p SO

I need to:
1) Go through each row of Col D; if it says 'SCO', then go to next row of
Col D.
2) If it says 'SO', then
a) If Col C 0, add the value in Col C to any other value in Col C
(going down)
until both Col A and Col B are < blank, and put that sum in Col C
on the
same row where both Col A and Col B are < blank, then erase the
individual entries in Col C used to come to that sum.
If during this process you ever find that both Col A and B are
blank, then
stop and go to the next row in Col D, and start over to see if it
says 'SO'
or 'SCO'.
b) If Col C is blank or = 0, then go to the next row of Col D and
start over to
see if it says 'SO' or 'SCO'.

I've struggled with this for quite some time and am desperately hoping
someone can help. The final product, using the example above and afer the
macro has run, should look like this:

Col A B C D
Description Type Charge Offering
Alert SO
Alert SO
Alert 9113 $35 SO
Perform SO
Perform SO
Perform 9220 $17 SO
Alert $19 SCO
Alert 8332 SCO
AA i/p $23 SO
AA i/p SO




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
Complex search, copy, and move opperation. Please HELP!!! Redoctober Excel Discussion (Misc queries) 3 September 9th 08 11:48 PM
Move names from Search to Excel Mark1 Excel Discussion (Misc queries) 5 October 27th 06 07:54 PM
Search and move?? Robert M. Gary[_2_] Excel Programming 4 November 18th 05 12:47 PM
How do I move data based on a conditional column search? bbaek Excel Programming 1 May 27th 05 04:17 PM
Search column and move text formula tommy Excel Discussion (Misc queries) 0 February 8th 05 06:55 PM


All times are GMT +1. The time now is 07:58 PM.

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

About Us

"It's about Microsoft Excel"