Search for value and return value from previous row

kazman101

New Member
Joined
Jul 19, 2011
Messages
7
HI All

Wondering if anyone can help, I have an excel sheet that has a list of status transitions, in the sheet there are system generated transitions because a user has forgotten to perform an action

I need to pull out a list of the userids involved which is in Column I, however if the system performs a transaction it shows the system userID "AUTO_UPDATE" the actual user ID is contained in either the previous row or the following row

does anyone know of a way I can put together a list of these users
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
kazman101,

Welcome to the MrExcel forum.

What version of Excel are you using?

You will generally get much more help (and faster) in this forum if you can post your small samples (what you have and what you expect to achieve) directly in the forum.

To attach screenshots, see below in my Signature block: Post a screen shot with one of these:
 
Upvote 0
Hi There

Thanks for the warm welcome, I'm currently using Excel 2007, I've followed your suggestion and attached a sample fo the data I have and what I am looking to acheive
 
Last edited:
Upvote 0
Hi There

Thanks for the warm welcome, I'm currently using Excel 2007,

Below is data from 4 columns, the status is in the third column and the user id is the 4th column, I'm looking to find the user ID of all instances where the Status was Auto-Suspend or where the user Id = AUTO_UPDATE


Application Full Started UK_skanchan
Application Full Auto-Suspend AUTO_UPDATE
Application Full Resume UK_skanchan
Application Full Finished UK_skanchan
Consumer_Email Short Started UK_skanchan
Consumer_Email Short Auto-Suspend AUTO_UPDATE
Consumer_Email Short Resume UK_skanchan
Consumer_Email Short Finished UK_skanchan
Customisation_Settings Delta Started UK_skanchan
Customisation_Settings Delta Finished UK_skanchan
Customisation_variant 1 Delta Started UK_skanchan
Customisation_variant 1 Delta Auto-Suspend AUTO_UPDATE
Customisation_variant 1 Delta Resume UK_skanchan
Customisation_variant 1 Delta Finished UK_skanchan
Exploratory Short Started UK_skanchan
Exploratory Short Auto-Suspend AUTO_UPDATE
Exploratory Short Resume UK_skanchan
 
Upvote 0
kazman101,

You have just pasted some text. It is difficult to see where your data resides in reference to the workskeet it is in.

And, you have not displayed an area where your output is to go.


You will generally get much more help (and faster) in this forum if you can post your small samples (what you have and what you expect to achieve) directly in the forum.

To attach screenshots, see below in my Signature block: Post a screen shot with one of these:

If you are not able to give us screenshots, see below in my Signature block: You can upload your workbook to Box Net, and provide us with a link to your workbook.
 
Last edited:
Upvote 0
kazman101,

Thanks for the workbook.

the actual user ID is contained in either the previous row or the following row


Can the actual user ID always be found in the previous row and always be found in the following row?
 
Upvote 0
Thanks for looking at it

Yes the UserID will always be in that location, the system orders it like that automatically
 
Upvote 0
kazman101,


Sample raw data in worksheet Status Transitions:


Excel Workbook
ABCDEFIJ
1VendorCommercial NameTestcycleTestareaTest TypeEffort TypeUser*
2**Acc-1/Acc 13G_HandsetDeltaLocalAddOnUK_nrohilla*
3**Acc-1/Acc 13G_HandsetDeltaLocalAddOnUK_nrohilla*
4**Acc-1/Acc 1ApplicationDeltaLocalAddOnUK_RJoseph*
5**Acc-1/Acc 1ApplicationDeltaLocalAddOnUK_RJoseph*
6**Acc-1/Acc 1ApplicationDeltaLocalAddOnUK_RJoseph*
7**Acc-1/Acc 1ApplicationDeltaLocalAddOnUK_RJoseph*
8**Acc-1/Acc 1ApplicationDeltaLocalAddOnUK_RJoseph*
9**Acc-1/Acc 1ApplicationDeltaLocalAddOnUK_RJoseph*
10**Acc-1/Acc 1ExploratoryDeltaLocalAddOnUK_RJoseph*
11**Acc-1/Acc 1ExploratoryDeltaLocalAddOnUK_RJoseph*
12**Acc-1/Acc 1Exploratory 2DeltaLocalAddOnUK_RJoseph*
13**Acc-1/Acc 1Exploratory 2DeltaLocalAddOnUK_RJoseph*
14**MR-5/MR1 for Gingerbread3G_HandsetShortLocalAddOnUK_nrohilla*
15**MR-5/MR1 for Gingerbread3G_HandsetShortLocalAddOnUK_nrohilla*
16**MR-5/MR1 for GingerbreadExploratoryShortLocalAddOnUK_mponnuswamy*
17**MR-5/MR1 for GingerbreadExploratoryShortLocalAddOnUK_mponnuswamy*
18**MR-2/QMR13G_HandsetShortLocalAddOnUK_nrohilla*
19**MR-2/QMR13G_HandsetShortLocalAddOnUK_nrohilla*
20**MR-2/QMR1Exploratory 2ShortLocalAddOnUK_mponnuswamy*
21**MR-2/QMR1Exploratory 2ShortLocalAddOnUK_mponnuswamy*
22**Acc-3/Acc 33G_HandsetDeltaLocalAddOnUK_nrohilla*
23**Acc-3/Acc 33G_HandsetDeltaLocalAddOnUK_nrohilla*
24**Acc-3/Acc 3ApplicationDeltaLocalAddOnUK_skanchan*
25**Acc-3/Acc 3ApplicationDeltaLocalAddOnUK_RJoseph*
26**Acc-3/Acc 3ApplicationDeltaLocalAddOnUK_skanchan*
27**Acc-3/Acc 3ApplicationDeltaLocalAddOnUK_skanchan*
28**Acc-3/Acc 3Exploratory 1b*DeltaLocalAddOnUK_mponnuswamy*
29**Acc-3/Acc 3Exploratory 1b*DeltaLocalAddOnUK_mponnuswamy*
30**Acc-3/Acc 3MR Sanity testsDeltaLocalAddOnUK_mponnuswamy*
31**Acc-3/Acc 3MR Sanity testsDeltaLocalAddOnUK_mponnuswamy*
32**Acc-3/Acc 3Previous IssuesDeltaLocalAddOnUK_mponnuswamy*
33**Acc-3/Acc 3Previous IssuesDeltaLocalAddOnUK_mponnuswamy*
34**Acc-1/Acc13G_HandsetFullLocalAddOnUK_nrohilla*
35**Acc-1/Acc13G_HandsetFullLocalAddOnAUTO_UPDATE*
36**Acc-1/Acc13G_HandsetFullLocalAddOnUK_nrohilla*
Status Transitions





After the first macro FindAU, a new filter is applied to the new column J Search, for AUTO_UPDATE, and we get this:


Excel Workbook
ABCDEFIJ
1VendorCommercial NameTestcycleTestareaTest TypeEffort TypeUserSearch
34**Acc-1/Acc13G_HandsetFullLocalAddOnUK_nrohillaAUTO_UPDATE
52**Acc-1/Acc1GPRS DeskFullLocalAddOnUK_nrohillaAUTO_UPDATE
72**Acc-1/Acc1SATFullLocalAddOnUK_ggargAUTO_UPDATE
84**Acc-1/Mac OS X Lion previewExploratoryDeltaLocalOnlyUK_RJosephAUTO_UPDATE
102**Acc-1/MR1ApplicationFullLocalAddOnUK_skanchanAUTO_UPDATE
106**Acc-1/MR1Consumer_EmailShortLocalAddOnUK_skanchanAUTO_UPDATE
112**Acc-1/MR1Customisation_variant 1DeltaLocalAddOnUK_skanchanAUTO_UPDATE
116**Acc-1/MR1ExploratoryShortLocalAddOnUK_skanchanAUTO_UPDATE
124**MR-2/MR2ExploratoryDeltaLocalAddOnUK_skanchanAUTO_UPDATE
130**Acc-1/ACC1/R5AA002ApplicationFullLocalAddOnUK_ggargAUTO_UPDATE
136**Acc-1/ACC1/R5AA002Content_TypesFullLocalAddOnUK_aradhakrishnanAUTO_UPDATE
140**Acc-1/ACC1/R5AA002Customisation_SettingsFullLocalAddOnUK_ggargAUTO_UPDATE
144**Acc-1/ACC1/R5AA002ExploratoryFullLocalAddOnUK_ggargAUTO_UPDATE
154**Acc-1/ACC1/R5AA002GSM_and_Basic_OperationsFullLocalAddOnUK_ggargAUTO_UPDATE
160**Acc-1/ACC1/R5AA002SATFullLocalAddOnUK_ggargAUTO_UPDATE
164**Acc-1/ACC1/R5AA002User_ExperienceFullLocalAddOnUK_ggargAUTO_UPDATE
174**Acc-1ApplicationFullLocalAddOnUK_aradhakrishnanAUTO_UPDATE
180**Acc-1Customisation_SettingsFullLocalAddOnUK_mponnuswamyAUTO_UPDATE
186**Acc-1MMSShortLocalAddOnUK_mponnuswamyAUTO_UPDATE
190**Acc-1Previous IssuesShortLocalAddOnUK_mponnuswamyAUTO_UPDATE
204**Acc-23G_HandsetShortLocalAddOnUK_nrohillaAUTO_UPDATE
212**Acc-2Customisation_SettingsFullLocalAddOnUK_mponnuswamyAUTO_UPDATE
216**Acc-2GSM - Screened RoomShortLocalAddOnUK_nrohillaAUTO_UPDATE
222**Acc-2Previous IssuesShortLocalAddOnUK_mponnuswamyAUTO_UPDATE
228**MR-2/MR2ApplicationFullLocalAddOnUK_aradhakrishnanAUTO_UPDATE
236**Acc-2/CAFApplicationDeltaLocalAddOnUK_skanchanAUTO_UPDATE
240**Acc-2/CAFCustomisation_SettingsDeltaLocalAddOnUK_RJosephAUTO_UPDATE
268**Acc-3/Acc-3Previous IssuesFullLocalAddOnUK_ggargAUTO_UPDATE
276********
Status Transitions





Then you manually apply the filter in column C, Testcycle, for Acc-1/Acc1 ,and we get this:


Excel Workbook
ABCDEFIJ
1VendorCommercial NameTestcycleTestareaTest TypeEffort TypeUserSearch
34**Acc-1/Acc13G_HandsetFullLocalAddOnUK_nrohillaAUTO_UPDATE
52**Acc-1/Acc1GPRS DeskFullLocalAddOnUK_nrohillaAUTO_UPDATE
72**Acc-1/Acc1SATFullLocalAddOnUK_ggargAUTO_UPDATE
276********
Status Transitions





Then we run the next macro STCopyAU, that creates worksheet Expected if it does not exist, or clears the sheet first, and then we get this:


Excel Workbook
ABCDEFG
1VendorCommercial NameTestcycleTestareaTest TypeEffort TypeUser
2**Acc-1/Acc13G_HandsetFullLocalAddOnUK_nrohilla
3**Acc-1/Acc13G_HandsetFullLocalAddOnUK_nrohilla
4**Acc-1/Acc13G_HandsetFullLocalAddOnUK_ggarg
5*******
Expected





Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
2. Open your workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


Code:
Option Explicit
Sub FindAU()
' hiker95, 07/20/2011
' http://www.mrexcel.com/forum/showthread.php?t=565303
Dim wS As Worksheet, wE As Worksheet
Dim c As Range, firstaddress As String
Application.ScreenUpdating = False
Set wS = Worksheets("Status Transitions")
wS.AutoFilterMode = False
wS.Columns("J").ClearContents
wS.Range("J1") = "Search"
With wS.Columns("I")
  Set c = .Find("AUTO_UPDATE", LookIn:=xlValues, LookAt:=xlWhole)
  If Not c Is Nothing Then
    firstaddress = c.Address
    Do
      c.Offset(-1, 1).Value = "AUTO_UPDATE"
      Set c = .FindNext(c)
    Loop While Not c Is Nothing And c.Address <> firstaddress
  End If
End With
wS.UsedRange.AutoFilter Field:=10, Criteria1:="AUTO_UPDATE"
Application.ScreenUpdating = True
End Sub


Sub STCopyAU()
' hiker95, 07/20/2011
' http://www.mrexcel.com/forum/showthread.php?t=565303
Dim wS As Worksheet, wE As Worksheet
Dim LR As Long, NR As Long, RC As Long
Application.ScreenUpdating = False
Set wS = Worksheets("Status Transitions")
If Not Evaluate("ISREF(Expected!A1)") Then Worksheets.Add(After:=wS).Name = "Expected"
Set wE = Worksheets("Expected")
wE.UsedRange.Clear
With wE.Range("A1:G1")
  .Value = [{"Vendor","Commercial Name","Testcycle","Testarea","Test Type","Effort Type","User"}]
  .Font.Bold = True
End With
LR = wS.Cells(Rows.Count, "C").End(xlUp).Row
On Error Resume Next
RC = 0
RC = Application.Subtotal(103, wS.Range("C1:C" & LR)) - 1
If RC > 1 Then
  NR = wE.Range("C" & Rows.Count).End(xlUp).Offset(1).Row
  wE.Range("A" & NR).Resize(RC, 6).Value = wS.Range("A1:F" & LR).Offset(1).Resize(wS.Rows.Count - 1).SpecialCells(12).Value
  wS.Range("I1:I" & LR).Offset(1).Resize(wS.Rows.Count - 1).SpecialCells(12).Copy wE.Range("G" & NR)
End If
wE.UsedRange.Columns.AutoFit
wE.Activate
Application.ScreenUpdating = True
End Sub


Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm


Then run the two macros, first macro FindAU, and in one of the other columns in the data filter, make a choice, and run the second macro STCopyAU that moves the found data to worksheet Expected.


The macro can be adjusted so that the data in worksheet Expected is not deleted, but added to.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top