ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help with loop (https://www.excelbanter.com/excel-programming/356741-help-loop.html)

sugargenius

help with loop
 
I need to process some data that looks like this:

02.01.01.01 PSE Staff
02.01.01.01 PSE Staff
02.01.01.01 PSE Staff
02.01.01.01 PSE Staff
02.03.01 Materials&Processes
02.03.01 Materials&Processes
02.03.02 Contamination Cntrl
02.03.02 Contamination Cntrl
02.07.02.01 Launch Sys Engrg
02.07.02.01 Launch Sys Engrg
02.08.01.01 Project Requirements
02.08.01.02 Project Requirements

There are more columns to the right that I need to summarize.

I need a loop (or maybe more than 1) to process each record and when
value in col A (task number) changes:

1. sum numeric cols from start of current "A" to end
2. delete duplicate labels after 1st row of current "A"

I'm sure this has been tackled before, so I hope someone can steer me
in the right direction. So far I have this:

Sub tester()
iRepRow = 2
sThisTask = Cells(iRepRow, 1)
sLastTask = sThisTask

Do
iThisTaskStartRow = iRepRow
Do
'get next
iRepRow = iRepRow + 1
sThisTask = Cells(iRepRow, 1)

'check for a new task
If sThisTask < sLastTask Then
'process this task here
Exit Do
End If

sLastTask = sThisTask
Loop

If iRepRow lMaxRow Then
Exit Do
End If
Loop
End Sub


Tom Ogilvy

help with loop
 
Use text to columns under the data menu to put your dat a in separate
columns. Then put in headers in the top row and create a Pivot Table (again
under the data menu)

--
Regards,
Tom Ogilvy

"sugargenius" wrote in message
oups.com...
I need to process some data that looks like this:

02.01.01.01 PSE Staff
02.01.01.01 PSE Staff
02.01.01.01 PSE Staff
02.01.01.01 PSE Staff
02.03.01 Materials&Processes
02.03.01 Materials&Processes
02.03.02 Contamination Cntrl
02.03.02 Contamination Cntrl
02.07.02.01 Launch Sys Engrg
02.07.02.01 Launch Sys Engrg
02.08.01.01 Project Requirements
02.08.01.02 Project Requirements

There are more columns to the right that I need to summarize.

I need a loop (or maybe more than 1) to process each record and when
value in col A (task number) changes:

1. sum numeric cols from start of current "A" to end
2. delete duplicate labels after 1st row of current "A"

I'm sure this has been tackled before, so I hope someone can steer me
in the right direction. So far I have this:

Sub tester()
iRepRow = 2
sThisTask = Cells(iRepRow, 1)
sLastTask = sThisTask

Do
iThisTaskStartRow = iRepRow
Do
'get next
iRepRow = iRepRow + 1
sThisTask = Cells(iRepRow, 1)

'check for a new task
If sThisTask < sLastTask Then
'process this task here
Exit Do
End If

sLastTask = sThisTask
Loop

If iRepRow lMaxRow Then
Exit Do
End If
Loop
End Sub





All times are GMT +1. The time now is 08:32 AM.

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