Hi Everyone,
I'm a new member and quite a beginner to VBA functions.
After trying different solutions, I decided to pop my first post here hoping to find a solution.
Let's see if I can explain Excel in... words
I receive a sheet from an external client which is not ideally set up, I mean it is quite a complex layout (for me) and I'm not able to find a way.
The sheet contains some information I want to pull out on a different sheet/tab and from there I'll make a random selection (I'm using Data Analysis pack for that).
The relevant information I want to be shown on the new tab (called "RPC") will be:
- Data in Column B (to be copied on RPC sheet in Column A)
- Data in Column O (to be copied on RPC sheet in Column B)
- Data in Column Y (to be copied on RPC sheet in Column C)
The result would be similar to the below:
Column A Column B Column C</SPAN>
[TABLE="width: 381"]
<TBODY>[TR]
[TD]Action Code </SPAN>
[/TD]
[TD]Number of calls per Code</SPAN>
[/TD]
[TD]Product</SPAN>
[/TD]
[/TR]
[TR]
[TD]
DCTELIEXEC</SPAN>
[/TD]
[TD]
1</SPAN>
[/TD]
[TD]
3746 000000 00001</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELINOK</SPAN>
[/TD]
[TD]9</SPAN>
[/TD]
[TD]3746 000000 00002</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00003</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00004</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00005</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00006</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00007</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00008</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00009</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00010</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELISOLS</SPAN>
[/TD]
[TD]1</SPAN>
[/TD]
[TD]3746 000000 00011</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
This is the list of Action Codes that has to be identified on Sheet1 between a larger number of Action Codes</SPAN>
[TABLE="width: 95"]
<TBODY>[TR]
[TD]DCTELIEXEC</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELINOK</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELISOLS</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELOEXEC</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELONOK1</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELOSOLS</SPAN>
[/TD]
[/TR]
[TR]
[TD]TELEATP01</SPAN>
[/TD]
[/TR]
[TR]
[TD]TELEOATP01</SPAN>
[/TD]
[/TR]
[TR]
[TD]TELICM01</SPAN>
[/TD]
[/TR]
[TR]
[TD]TELIDEB01</SPAN>
[/TD]
[/TR]
[TR]
[TD]TELOCM01</SPAN>
[/TD]
[/TR]
[TR]
[TD]TELOCM02</SPAN>
[/TD]
[/TR]
[TR]
[TD]TELOCM03</SPAN>
[/TD]
[/TR]
[TR]
[TD]TELOCM04</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
So far I'm able to run the macro and copy only 1 Action Code, because I don't know how to add multiple criteria.
What I would like to get will be a macro which:
- Identifies the above 14 Action Codes between a larger range of codes
- If an Action code has # of calls, macro should be able to identify the same number of Products; after verifying that # of calls equals to # of Product, macro should go to check the next criteria/Action Code - is it possible to have a control formula at this point? such as: "check number of calls, find same number of products; only after that, go to the next criteria"
- All the identified Action Codes, No. of calls and Products should be copied into the "RPC" sheet and appear like that:
Column A Column B Column C</SPAN>
[TABLE="width: 381"]
<TBODY>[TR]
[TD]Action Code </SPAN>
[/TD]
[TD]Number of calls per Code</SPAN>
[/TD]
[TD]Product</SPAN>
[/TD]
[/TR]
[TR]
[TD]
DCTELIEXEC</SPAN>
[/TD]
[TD]
1</SPAN>
[/TD]
[TD]
3746 000000 00001</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELINOK</SPAN>
[/TD]
[TD]9</SPAN>
[/TD]
[TD]3746 000000 00002</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00003</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00004</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00005</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00006</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00007</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00008</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00009</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00010</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELISOLS</SPAN>
[/TD]
[TD]1</SPAN>
[/TD]
[TD]3746 000000 00011</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
The main issue for me is that data referring to the same case are not in the same row.
Example:
the Product linked to Action Code DCTELIEXEC (located in B7) is Y19, whereas the number of calls is in O8
I found a kind of pattern if helps:
Action code is in B Column
Number of call is in Column O + 1 row + 13 columns right
Product is in Column Y + 12 rows down + 23 columns right (from Action Code position)
Based on the thread "Macro to find specific text in a column and copy certain cells in same row to a different sheet"
I'm using the following code, but I can't have the related Product shown aside of it and I don't know how to add multiple criterias (the 14 Action Codes) to the Code of the Macro:
Sub Sheet1()
Dim shts As Worksheet, i As Integer
Application.ScreenUpdating = False
'Sheets("RPC").Range("A2:" & Columns.Count & ":" & Rows.Count).Delete
i = 1
For Each shts In Worksheets
If shts.Name Like "Sheet1*" Then
shts.UsedRange.AutoFilter Field:=2, Criteria1:="DCTELIEXEC"
Sheets(i).Range(Sheets(i).Range("B3:B18084").Offset(1), Sheets(i).Range("B3:B18084").End(xlDown)).Copy _
Sheets("RPC").Range("A" & Rows.Count).End(xlUp).Offset(1)
shts.UsedRange.AutoFilter
End If
i = i + 1
Application.ScreenUpdating = True
Next
End Sub
Please let me know if you need to see the original sheet and give me some instructions on how to upload it.
Thank you very much for your help.
Regards,
Brikkio</SPAN>
I'm a new member and quite a beginner to VBA functions.
After trying different solutions, I decided to pop my first post here hoping to find a solution.
Let's see if I can explain Excel in... words
I receive a sheet from an external client which is not ideally set up, I mean it is quite a complex layout (for me) and I'm not able to find a way.
The sheet contains some information I want to pull out on a different sheet/tab and from there I'll make a random selection (I'm using Data Analysis pack for that).
The relevant information I want to be shown on the new tab (called "RPC") will be:
- Data in Column B (to be copied on RPC sheet in Column A)
- Data in Column O (to be copied on RPC sheet in Column B)
- Data in Column Y (to be copied on RPC sheet in Column C)
The result would be similar to the below:
Column A Column B Column C</SPAN>
[TABLE="width: 381"]
<TBODY>[TR]
[TD]Action Code </SPAN>
[/TD]
[TD]Number of calls per Code</SPAN>
[/TD]
[TD]Product</SPAN>
[/TD]
[/TR]
[TR]
[TD]
DCTELIEXEC</SPAN>
[/TD]
[TD]
1</SPAN>
[/TD]
[TD]
3746 000000 00001</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELINOK</SPAN>
[/TD]
[TD]9</SPAN>
[/TD]
[TD]3746 000000 00002</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00003</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00004</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00005</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00006</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00007</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00008</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00009</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00010</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELISOLS</SPAN>
[/TD]
[TD]1</SPAN>
[/TD]
[TD]3746 000000 00011</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
This is the list of Action Codes that has to be identified on Sheet1 between a larger number of Action Codes</SPAN>
[TABLE="width: 95"]
<TBODY>[TR]
[TD]DCTELIEXEC</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELINOK</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELISOLS</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELOEXEC</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELONOK1</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELOSOLS</SPAN>
[/TD]
[/TR]
[TR]
[TD]TELEATP01</SPAN>
[/TD]
[/TR]
[TR]
[TD]TELEOATP01</SPAN>
[/TD]
[/TR]
[TR]
[TD]TELICM01</SPAN>
[/TD]
[/TR]
[TR]
[TD]TELIDEB01</SPAN>
[/TD]
[/TR]
[TR]
[TD]TELOCM01</SPAN>
[/TD]
[/TR]
[TR]
[TD]TELOCM02</SPAN>
[/TD]
[/TR]
[TR]
[TD]TELOCM03</SPAN>
[/TD]
[/TR]
[TR]
[TD]TELOCM04</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
So far I'm able to run the macro and copy only 1 Action Code, because I don't know how to add multiple criteria.
What I would like to get will be a macro which:
- Identifies the above 14 Action Codes between a larger range of codes
- If an Action code has # of calls, macro should be able to identify the same number of Products; after verifying that # of calls equals to # of Product, macro should go to check the next criteria/Action Code - is it possible to have a control formula at this point? such as: "check number of calls, find same number of products; only after that, go to the next criteria"
- All the identified Action Codes, No. of calls and Products should be copied into the "RPC" sheet and appear like that:
Column A Column B Column C</SPAN>
[TABLE="width: 381"]
<TBODY>[TR]
[TD]Action Code </SPAN>
[/TD]
[TD]Number of calls per Code</SPAN>
[/TD]
[TD]Product</SPAN>
[/TD]
[/TR]
[TR]
[TD]
DCTELIEXEC</SPAN>
[/TD]
[TD]
1</SPAN>
[/TD]
[TD]
3746 000000 00001</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELINOK</SPAN>
[/TD]
[TD]9</SPAN>
[/TD]
[TD]3746 000000 00002</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00003</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00004</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00005</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00006</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00007</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00008</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00009</SPAN>
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]3746 000000 00010</SPAN>
[/TD]
[/TR]
[TR]
[TD]DCTELISOLS</SPAN>
[/TD]
[TD]1</SPAN>
[/TD]
[TD]3746 000000 00011</SPAN>
[/TD]
[/TR]
</TBODY>[/TABLE]
The main issue for me is that data referring to the same case are not in the same row.
Example:
the Product linked to Action Code DCTELIEXEC (located in B7) is Y19, whereas the number of calls is in O8
I found a kind of pattern if helps:
Action code is in B Column
Number of call is in Column O + 1 row + 13 columns right
Product is in Column Y + 12 rows down + 23 columns right (from Action Code position)
Based on the thread "Macro to find specific text in a column and copy certain cells in same row to a different sheet"
I'm using the following code, but I can't have the related Product shown aside of it and I don't know how to add multiple criterias (the 14 Action Codes) to the Code of the Macro:
Sub Sheet1()
Dim shts As Worksheet, i As Integer
Application.ScreenUpdating = False
'Sheets("RPC").Range("A2:" & Columns.Count & ":" & Rows.Count).Delete
i = 1
For Each shts In Worksheets
If shts.Name Like "Sheet1*" Then
shts.UsedRange.AutoFilter Field:=2, Criteria1:="DCTELIEXEC"
Sheets(i).Range(Sheets(i).Range("B3:B18084").Offset(1), Sheets(i).Range("B3:B18084").End(xlDown)).Copy _
Sheets("RPC").Range("A" & Rows.Count).End(xlUp).Offset(1)
shts.UsedRange.AutoFilter
End If
i = i + 1
Application.ScreenUpdating = True
Next
End Sub
Please let me know if you need to see the original sheet and give me some instructions on how to upload it.
Thank you very much for your help.
Regards,
Brikkio</SPAN>