Complicated transpose of data with conditions

mahmed1

Well-known Member
Joined
Mar 28, 2009
Messages
2,302
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I have this data set that i need to transpose but i dont know exactly where to start to explain what im trying to do so i will try my best to explain

I have a data set that looks like this


Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAI
1Respondent IDCollector IDStart DateEnd DateIP AddressEmail AddressFirst NameLast NameCustom Data 1Please enter the Unique Reference Number of the training you attended (you can copy & paste this from the email you have received)AreaPlease enter the programme name of the training you attended (you can copy & paste this from the email you have received)Please select from the drop down menu the lead trainer for the sessionYour name:Your base site:For each of the statements below, let us know how strongly you agree with the statement, where 1 = strongly disagree and 5 = strongly agreeHow could we improve the invitation for you next time?For each of the statements below, let us know how strongly you agree with the statement, where 1 = strongly disagree and 5 = strongly agreeHow could we improve the training event for you next time?For each of the statements below, let us know how strongly you agree with the statement, where 1 = strongly disagree and 5 = strongly agreeHow could we improve the environment/resources for you next time?
2Open-Ended ResponseOpen-Ended ResponseResponseOther (please specify)Open-Ended ResponseResponseOther (please specify)I received an invitation with sufficient noticeThe invitation was inviting and engagingI was clear about venues, dates and timingsI was clear about the purpose of the trainingI understood why I had been invitedThe preparation made sense given the purposeOpen-Ended ResponseI was fully engaged throughout the training eventI felt able to ask questions and ask for helpThe practical sessions helped bring the theory to lifeThe pace of the training worked for meI am confident I can apply my learningI am clear about the support I can expect after the training eventOpen-Ended ResponseThe training space, equipment & materials all worked for meThe group size worked wellThe duration of the training was just right given what we were learningOpen-Ended Response
3testtest2018-05-17 16:33:432018-05-17 16:35:43testtest102-TR-May-18-7-TM1TM1PROGRAMME1Name1Name 1Other (please specify)Lake House444444TEST444444TEST344TEST
4testtest2018-05-17 16:09:182018-05-17 16:23:53testtest102-TR-May-18-7-TM1TM1PROGRAMME1Name1Name 2Derby555444TEST555555TEST255TEST
5testtest2018-05-17 14:55:222018-05-17 14:57:15testtest102-TR-May-18-7-TM1TM1PROGRAMME1Name1Name 3London454444...................52153TEST345TEST
6testtest2018-05-17 14:23:452018-05-17 14:25:39testtest102-TR-May-18-7-TM1TM1PROGRAMME1Name1Name 4London555444NA12345N/ATEST333TEST
7testtest2018-05-17 14:01:012018-05-17 14:02:54testtest102-TR-May-18-7-TM1TM1PROGRAMME2Name1Name 5Other (please specify)na342444NA444444TEST435TEST
8testtest2018-05-17 13:46:262018-05-17 13:48:17testtest102-TR-May-18-7-TM1TM1PROGRAMME2Name1Name 6Manchester555444NA555554TEST555TEST
9testtest2018-05-17 13:10:122018-05-17 13:12:02testtest102-TR-May-18-7-TM1TM1PROGRAMME2Name1Name 7Manchester444444NA544544TEST433TEST
10testtest2018-05-17 13:07:452018-05-17 13:11:25testtest102-TR-May-18-7-TM1TM1PROGRAMME2Name1Name 8Derby111444NA555555N/A131NA
11testtest2018-05-17 13:05:462018-05-17 13:09:22testtest102-TR-May-18-7-TM1TM1PROGRAMME2Name1Name 9Manchester555444NAN/AN/AN/AN/AN/AN/AN/AN/AN/AN/ANA
12testtest2018-05-14 14:31:512018-05-14 14:53:40testtest95-TR-May-18-5-TM2TM2PROGRAMME3Name1Name 10Manchester425444NA544545N/A325NA
13testtest2018-05-11 15:08:442018-05-11 15:15:42testtest95-TR-May-18-5-TM2TM2PROGRAMME3Name1Name 11London555444NA55N/A355N/A553NA
14testtest2018-05-11 15:06:212018-05-11 15:08:36testtest95-TR-May-18-5-TM2TM2PROGRAMME3Name 2Name 12Manchester345444NA333333N/A344NA
15testtest2018-05-11 13:53:402018-05-11 13:56:30testtest95-TR-May-18-5-TM2TM2PROGRAMME3Name 3Name 13London435444NA453451N/A413NA
16testtest2018-05-11 13:53:382018-05-11 13:57:32testtest95-TR-May-18-5-TM2TM2PROGRAMME3Name 1Name 14London545444NA555553N/A135NA
Learner 1(


I want to transpose the data so all the questions are split out on individual rows in order for me to be able to slice and use in my pivot table

Output like this


Cell Formulas
RangeFormula
A1Respondent ID
A2test
A3test
A4test
A5test
A6test
A7test
A8test
A9test
A10test
B1Name
B2Name 1
B3Name 1
B4Name 1
B5Name 1
B6Name 1
B7Name 1
B8Name 1
B9Name 1
B10Name 1
C1Date
C243237
C343237
C443237
C543237
C643237
C743237
C843237
C943237
C1043237
D1Type
D2Learner 1(<2hrs)
D3Learner 1(<2hrs)
D4Learner 1(<2hrs)
D5Learner 1(<2hrs)
D6Learner 1(<2hrs)
D7Learner 1(<2hrs)
D8Learner 1(<2hrs)
D9Learner 1(<2hrs)
D10Learner 1(<2hrs)
E1Section
E2INVITATION
E3INVITATION
E4INVITATION
E5INVITATION
E6INVITATION
E7INVITATION
E8TRAINING EVENT
E9TRAINING EVENT
E10TRAINING EVENT
F1URN
F2102-TR-May-18-7-TM1
F3102-TR-May-18-7-TM1
F4102-TR-May-18-7-TM1
F5102-TR-May-18-7-TM1
F6102-TR-May-18-7-TM1
F7102-TR-May-18-7-TM1
F8102-TR-May-18-7-TM1
F9102-TR-May-18-7-TM1
F10102-TR-May-18-7-TM1
G1Area
G2TM1
G3TM1
G4TM1
G5TM1
G6TM1
G7TM1
G8TM1
G9TM1
G10TM1
H1Programme Name
H2PROGRAMME1
H3PROGRAMME1
H4PROGRAMME1
H5PROGRAMME1
H6PROGRAMME1
H7PROGRAMME1
H8PROGRAMME1
H9PROGRAMME1
H10PROGRAMME1
I1Lead Trainer Name
I2Name1
I3Name1
I4Name1
I5Name1
I6Name1
I7Name1
I8Name1
I9Name1
I10Name1
J1Base Site
J2Lake House
J3Lake House
J4Lake House
J5Lake House
J6Lake House
J7Lake House
J8Lake House
J9Lake House
J10Lake House
K1Question
K2I received an invitation with sufficient notice
K3I was clear about the purpose of the training
K4I was clear about venues, dates and timings
K5The invitation was inviting and engaging
K6The preparation made sense given the purpose
K7I understood why I had been invited
K8I was fully engaged throughout the training event
K9I felt able to ask questions and ask for help
K10The practical sessions helped bring the theory to life
L1Rating
L24
L34
L44
L54
L64
L74
L84
L94
L104


These are the criterias

I have 5 sheets to look at in my workbook however each sheet does not have the data in the same columns
The Header is in row1 and any questions appear to be in row 2
All the output - results appear to start from row 3
The questions that in row 2 also have the word Open Response - those questions can be ignored and not required
Each section has different amount questions

I have a list of questions for each type and section - I need to look at the range of questions in my look up table and then match it in the Raw Data table and get the result of that question (All the questions should be in the RAW DATA however if for whatever reason it aint then we can look at the next question)

The Question Lookup range looks like this


Book1
BCDEFGHIJKLMN
2# OF QUESTIONSTYPESECTIONQ1Q2Q3Q4Q5Q6Q7Q8Q9Q10
36Learner 1 (<2hrs)INVITATIONI received an invitation with sufficient noticeI was clear about the purpose of the trainingI was clear about venues, dates and timingsThe invitation was inviting and engagingThe preparation made sense given the purposeI understood why I had been invited
410Learner 1 (<2hrs)TRAINING EVENTI was fully engaged throughout the training eventI had a clear view of the learning agenda & daily prioritiesI felt able to ask questions and ask for helpThe assessments helped me test my learningThe practical sessions helped bring the theory to lifeThe pace of the training worked for meI am excited about putting my learning into practiceI am confident I will have the opportunity to put my learning into practiceI am clear about the support I can expect after the training eventI understand how this learning can help me be successful in my role
56Learner 1 (<2hrs)THE LEARNING ENVIRONMENT & RESOURCESThe training space worked for meWe had all the equipment we needed and it always workedThe slides, materials and handouts made learning easierI am confident I will use the handouts and notes to help me when I'm 'live'The group size worked wellThe duration of the training was just right given what we were learning
6
7
8TYPESECTIONQ1Q2Q3Q4Q5Q6Q7Q8Q9Q10
93Learner 1 (>2hrs)INVITATIONI received an invitation with sufficient notice and all info I neededThe invitation was inviting and engagingI understood why I had been invited
106Learner 1 (>2hrs)TRAINING EVENTI was fully engaged throughout the training eventI felt able to ask questions and ask for helpThe practical sessions helped bring the theory to lifeThe pace of the training worked for meI am confident I can apply my learningI am clear about the support I can expect after the training event
113Learner 1 (>2hrs)THE LEARNING ENVIRONMENT & RESOURCESTraining space, equipment and materials all worked for meThe duration of the training was just right given what we were learningThe group size worked for me
12
13
14TYPESECTIONQ1Q2Q3Q4Q5Q6Q7Q8Q9Q10
154Learner 2SINCE THE TRAININGI have been able to put the learning into practice and my confidence is increasing as a resultI have had the support I need to successfully apply what I learnedThe training has helped me perform better in my roleThe training will help me perform better in my role in the future
16
17
18TYPESECTIONQ1Q2Q3Q4Q5Q6Q7Q8Q9Q10
193TL FeedbackSET UPI was clear about the purpose of the trainingI had the right amount of contact and involvement with L&D in the run upI was happy with the design of the training and what it would deliver
206TL FeedbackTRAINING EVENTI fully understood what was expected of me during the trainingThe training was well managedThe training was delivered in an engaging and interesting way (personal experience)If N/A-didn't attend, branch to: The training was delivered in an engaging and interesting way (other's reports)I am satisfied with the updates and communication I received throughoutI am satisfied with the capability of the Learners at this point
215TL FeedbackREINFORCEMENTI understood what I could expect from L&D in terms of supporting reinforcementI understood what my role was in reinforcing the learningI am satisfied with how L&D collaborated with me/us after the trainingThe reinforcement went as plannedI am satisfied that the reinforcement activity was successful
22
23
24TYPESECTIONQ1Q2Q3Q4Q5Q6Q7Q8Q9Q10
259Stake FeedbackRESOURCE & CLIENT MANAGEMENTI have the right amount of communication with L&D management and what we cover is relevant/useful to meMy expectations are managed effectively and consistentlyI am challenged appropriately and positively when necessaryL&D are proactive in their support of me and my businessL&D provide useful and effective feedback and reflectionL&D are credible learning and development professionals in my eyesL&D processes, templates, SLAs and rules of engagement work for me and support collaborative workingTraining resources are managed effectivelyL&D are responsive and solution-oriented, particularly under pressure
266Stake FeedbackDELIVERING OUTCOMESRegarding Design of learning journeys and materials, I am satisfied with what has been deliveredI am satisfied with how my SMEs and managers have been involved in design and delivery of learningClassroom delivery has met my highest expectationsCoaching and reinforcement activity as been appropriate and effectiveI am satisfied that the skills and capability that have been delivered through L&D programmes have met the agreed briefI am satisfied that learning activity in this period has delivered the behaviours and mindset we need to meet our objectives
Sheet3
Cell Formulas
RangeFormula
B3=COUNTA(E3:X3)
B4=COUNTA(E4:X4)
B5=COUNTA(E5:X5)
B9=COUNTA(E9:X9)
B10=COUNTA(E10:X10)
B11=COUNTA(E11:X11)
B15=COUNTA(E15:X15)
B19=COUNTA(E19:X19)
B20=COUNTA(E20:X20)
B21=COUNTA(E21:X21)
B25=COUNTA(E25:X25)
B26=COUNTA(E26:X26)


So when i look at the 1st sheet (this is determined by the TYPE name) - i need to look at each question for each section
I need to match the question for the 1st agent and retrieve all that data and repeat again (the section name will be the question im looking at for that section)

All i know is that column A will have every data filled in so the last row can be determined by column A and last column can be determined by row 2 which is the question row)
If what whatever reason the answer the question is anything other than a number (blank,?, NA etc) then return a 0

The Survey header range is named differently to the final output

Here is the range for how it appears in the rawdata (so i will need to look at that title header) in that sheet and return that value and paste in the relevant column on the output sheet


Cell Formulas
RangeFormula
B1Appears in Survey Monkey
B3Respondent ID
B4Your name:
B5Start Date
B6Please enter the Unique Reference Number of the training you attended (you can copy & paste this from the email you have received)
B7Please enter the programme name of the training you attended (you can copy & paste this from the email you have received)
B8Please select from the drop down menu the lead trainer for the session
B9Please enter your Area name
B10Your base site:
B11Other (please specify)
B12Der
B13Brum
B14Lon
B15N/A
C1Final Output
C3Respondent ID
C4Name
C5Date
C6URN
C7Programme Name
C8Lead Trainer Name
C9Area
C10Base Site
C11OTHER
C12Derby
C13Bham
C14London
C150
A3Header
A4Header
A5Header
A6Header
A7Header
A8Header
A9Header
A10Header
A11Results
A12Results
A13Results
A14Results
A15Results


If the base site says Other (please specify) then look at the cell offset 1 to the right and see if it has any value in there (if it is blank or has N/A) then display OTHER
other than that look at the table and find the base site specified and change to the actual name found in the table specified

I really hope this is enough information

My aim is to just transpose all the data split by question but the main problem is that the questions are not in the same order and nor is the title - once that sheet is done - look at the next sheet and repeat process (when looking at the next sheet, the question range will change) again determined by the type name - that would be the next lookuprange

Thank You
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi all - i know the previous message looks messy so please ignore it if it dont make sense - i have had a go at writing some code and so far ive got it to work ok to input all title/header rows

Output of question column is Column 11

This is where i need to look at the sheet im looping through and then get which question section i need to look at

I have created a named range that has the sheet name and then the named range of the range it needs to look at ITS CALLED (QuestionLookup)

eg - if im on sheet Learner 1 (<2hrs) - on the next column i have have put the named range of L1_Less2hrs (Ive created a named range call this)

Here is the lookup range

Type (Sheet Name)Named Range
Learner 1 (<2hrs)L1_Less2hrs
Learner 1 (>2hrs)L1_More2hrs
Learner 2Learner2
TL FeedbackTL_Feedback
Stake FeedbackStake_Feedback

<colgroup><col><col></colgroup><tbody>
</tbody>

This named range has multiple rows that lists each section and then a list of questions for each section (In column B) i have put a count of how many questions i have for each section

Before i move on to the next agent - i need to loop through each question - get the rating and in put into the rating column (Output sheet column 12), i need input the question im looping through and put that in outputsheet column (11) and put the section name (in output sheet column 5)

the question lookup looks like this (L1_less2hrs lookup range)

# OF QUESTIONSTYPESECTIONQ1Q2
6Learner 1 (<2hrs)INVITATIONI received an invitation with sufficient noticeI was clear about the purpose of the training
10Learner 1 (<2hrs)TRAINING EVENTI was fully engaged throughout the training eventI had a clear view of the learning agenda & daily priorities
6Learner 1 (<2hrs)THE LEARNING ENVIRONMENT & RESOURCESThe training space worked for meWe had all the equipment we needed and it always worked

<tbody>
</tbody>

So the main thing im trying to do is just purely Seperate the questions by row - get the rating and input the section
the question lookup range depends on what sheet im looping through

hope this makes sense as im nearly there but dont know how to get to the final line

Thank You

Here is the VBA code ive tried to put together

Code:
Sub transposeme()


Dim RawDatash As Worksheet
Dim Outputsh As Worksheet
Dim RefSh As Worksheet
Dim QuestionSh As Worksheet
Dim ws As Worksheet


Dim i As Long
Dim Startrow As Long
Dim Lrow As Long
Dim Lcol As Long
Dim RawDataCol As Long
Dim OutputLR As Long
Dim MatchHeaders As Long


Dim myType As String
Dim BaseSite As String


Set RawDatash = Worksheets("Learner 1(<2hrs)")
Set Outputsh = Worksheets("Output")
Set RefSh = Worksheets("Ref")
Set QuestionSh = Worksheets("Q Sheet")


'start row of data output from raw data
Startrow = 3


Lrow = RawDatash.Range("A" & Rows.Count).End(xlUp).Row
Lcol = RawDatash.Cells(2, Columns.Count).End(xlToLeft).Column
OutputLR = Outputsh.Range("A" & Rows.Count).End(xlUp).Row
        
        
    For Each ws In ThisWorkbook.Worksheets
            'skip these sheets
        If ws.Name <> "Ref" Or ws.Name <> "Output" Or ws.Name <> "Q Sheet" Then
            
            'Loop through each agent
        For i = Startrow To Lrow
            myType = ws.Name
            
            'Loop through headers
            
                'Respondant
                MatchHeaders = Application.WorksheetFunction.Match(RefSh.ListObjects("HeaderTable").ListColumns("Appears in Survey Monkey").DataBodyRange(1), RawDatash.Range(RawDatash.Cells(1, 1), RawDatash.Cells(1, Lcol)), 0)
                Outputsh.Cells(OutputLR, 1).Value = RawDatash.Cells(i, MatchHeaders)
                
                'Name
                MatchHeaders = Application.WorksheetFunction.Match(RefSh.ListObjects("HeaderTable").ListColumns("Appears in Survey Monkey").DataBodyRange(2), RawDatash.Range(RawDatash.Cells(1, 1), RawDatash.Cells(1, Lcol)), 0)
                Outputsh.Cells(OutputLR, 2).Value = RawDatash.Cells(i, MatchHeaders)
                
                
                'Date
                MatchHeaders = Application.WorksheetFunction.Match(RefSh.ListObjects("HeaderTable").ListColumns("Appears in Survey Monkey").DataBodyRange(3), RawDatash.Range(RawDatash.Cells(1, 1), RawDatash.Cells(1, Lcol)), 0)
                Outputsh.Cells(OutputLR, 3).Value = DateValue(RawDatash.Cells(i, MatchHeaders))
                
                
                'URN
                MatchHeaders = Application.WorksheetFunction.Match(RefSh.ListObjects("HeaderTable").ListColumns("Appears in Survey Monkey").DataBodyRange(4), RawDatash.Range(RawDatash.Cells(1, 1), RawDatash.Cells(1, Lcol)), 0)
                Outputsh.Cells(OutputLR, 6).Value = RawDatash.Cells(i, MatchHeaders)
                
                'Area
                MatchHeaders = Application.WorksheetFunction.Match(RefSh.ListObjects("HeaderTable").ListColumns("Appears in Survey Monkey").DataBodyRange(6), RawDatash.Range(RawDatash.Cells(1, 1), RawDatash.Cells(1, Lcol)), 0)
                Outputsh.Cells(OutputLR, 7).Value = RawDatash.Cells(i, MatchHeaders)
                
    
                'Programme Name
                MatchHeaders = Application.WorksheetFunction.Match(RefSh.ListObjects("HeaderTable").ListColumns("Appears in Survey Monkey").DataBodyRange(5), RawDatash.Range(RawDatash.Cells(1, 1), RawDatash.Cells(1, Lcol)), 0)
                Outputsh.Cells(OutputLR, 8).Value = RawDatash.Cells(i, MatchHeaders)
                
                
                'Lead Trainer
                MatchHeaders = Application.WorksheetFunction.Match(RefSh.ListObjects("HeaderTable").ListColumns("Appears in Survey Monkey").DataBodyRange(6), RawDatash.Range(RawDatash.Cells(1, 1), RawDatash.Cells(1, Lcol)), 0)
                Outputsh.Cells(OutputLR, 9).Value = RawDatash.Cells(i, MatchHeaders)
                  
                'Base Site
                MatchHeaders = Application.WorksheetFunction.Match(RefSh.ListObjects("HeaderTable").ListColumns("Appears in Survey Monkey").DataBodyRange(8), RawDatash.Range(RawDatash.Cells(1, 1), RawDatash.Cells(1, Lcol)), 0)
   
                    Select Case RawDatash.Cells(i, MatchHeaders)
                        Case Is = "Other (please specify)"
                                BaseSite = "OTHER"
                        Case Is = "Lon"
                                BaseSite = "London"
                        Case Is = "Der"
                                BaseSite = "Derby"
                        Case Else
                                BaseSite = "OTHER"
                    End Select
                    Outputsh.Cells(OutputLR, 10).Value = BaseSite
                
                'Type
                Outputsh.Cells(OutputLR, 4).Value = myType
            
            '''#####STUCK HERE####'''''
            
            'Section Name
            'Outputsh.Cells(OutputLR, 5).Value
            
            'Question
            'Outputsh.Cells(OutputLR, 11).Value
            
            'Rating
            'Outputsh.Cells(OutputLR, 12).Value
            
            OutputLR = OutputLR + 1
            
            'Loop through each question and seperate them on its own lineand then move onto next agent and repeat
            'once done go to next sheet and follow same steps
            'Question range depends on which sheet im on
            ''''#################'''''''
            
            
        Next i
       End If
    Next ws
End Sub
 
Last edited:
Upvote 0
Hi - I managed to input and look at the correct named range and loop over all questions for that question section - the bit that it fails currently is that once it loops through one question - i need to go to the next row on the output sheet to look at the next question but not the next agent as ill need to loop through all the questions 1st - all the rows for that agent should be the same except the questions and rating will be different

If there is no match - i currently have on error resume next but i guess there will be a better way to do it

Please - i know post 1 is confusing and i wish i could delete it but hopefully just need tweaking this code and if this code can be mademore efficient - would really appreciate if you could help me with that

thank you
Code:
Sub transposeme()


Dim RawDatash As Worksheet
Dim Outputsh As Worksheet
Dim RefSh As Worksheet
Dim QuestionSh As Worksheet
Dim ws As Worksheet
Dim QuestionRange As Range


Dim i As Long
Dim Startrow As Long
Dim Lrow As Long
Dim Lcol As Long
Dim RawDataCol As Long
Dim OutputLR As Long
Dim MatchHeaders As Long


Dim myType As String
Dim BaseSite As String


Set RawDatash = Worksheets("Learner 1(<2hrs)")
Set Outputsh = Worksheets("Output")
Set RefSh = Worksheets("Ref")
Set QuestionSh = Worksheets("Q Sheet")


'start row of data output from raw data
Startrow = 3


Lrow = RawDatash.Range("A" & Rows.Count).End(xlUp).Row
Lcol = RawDatash.Cells(2, Columns.Count).End(xlToLeft).Column
OutputLR = Outputsh.Range("A" & Rows.Count).End(xlUp).Row
        
        
    For Each ws In ThisWorkbook.Worksheets
            'skip these sheets
        If ws.Name <> "Ref" Or ws.Name <> "Output" Or ws.Name <> "Q Sheet" Then
            
            'Loop through each agent
        For i = Startrow To Lrow
            myType = ws.Name
            
            'Loop through headers
            
                'Respondant
                MatchHeaders = Application.WorksheetFunction.Match(RefSh.ListObjects("HeaderTable").ListColumns("Appears in Survey Monkey").DataBodyRange(1), RawDatash.Range(RawDatash.Cells(1, 1), RawDatash.Cells(1, Lcol)), 0)
                Outputsh.Cells(OutputLR, 1).Value = RawDatash.Cells(i, MatchHeaders)
                
                'Name
                MatchHeaders = Application.WorksheetFunction.Match(RefSh.ListObjects("HeaderTable").ListColumns("Appears in Survey Monkey").DataBodyRange(2), RawDatash.Range(RawDatash.Cells(1, 1), RawDatash.Cells(1, Lcol)), 0)
                Outputsh.Cells(OutputLR, 2).Value = RawDatash.Cells(i, MatchHeaders)
                
                
                'Date
                MatchHeaders = Application.WorksheetFunction.Match(RefSh.ListObjects("HeaderTable").ListColumns("Appears in Survey Monkey").DataBodyRange(3), RawDatash.Range(RawDatash.Cells(1, 1), RawDatash.Cells(1, Lcol)), 0)
                Outputsh.Cells(OutputLR, 3).Value = DateValue(RawDatash.Cells(i, MatchHeaders))
                
                
                'URN
                MatchHeaders = Application.WorksheetFunction.Match(RefSh.ListObjects("HeaderTable").ListColumns("Appears in Survey Monkey").DataBodyRange(4), RawDatash.Range(RawDatash.Cells(1, 1), RawDatash.Cells(1, Lcol)), 0)
                Outputsh.Cells(OutputLR, 6).Value = RawDatash.Cells(i, MatchHeaders)
                
                'Area
                MatchHeaders = Application.WorksheetFunction.Match(RefSh.ListObjects("HeaderTable").ListColumns("Appears in Survey Monkey").DataBodyRange(6), RawDatash.Range(RawDatash.Cells(1, 1), RawDatash.Cells(1, Lcol)), 0)
                Outputsh.Cells(OutputLR, 7).Value = RawDatash.Cells(i, MatchHeaders)
                
    
                'Programme Name
                MatchHeaders = Application.WorksheetFunction.Match(RefSh.ListObjects("HeaderTable").ListColumns("Appears in Survey Monkey").DataBodyRange(5), RawDatash.Range(RawDatash.Cells(1, 1), RawDatash.Cells(1, Lcol)), 0)
                Outputsh.Cells(OutputLR, 8).Value = RawDatash.Cells(i, MatchHeaders)
                
                
                'Lead Trainer
                MatchHeaders = Application.WorksheetFunction.Match(RefSh.ListObjects("HeaderTable").ListColumns("Appears in Survey Monkey").DataBodyRange(6), RawDatash.Range(RawDatash.Cells(1, 1), RawDatash.Cells(1, Lcol)), 0)
                Outputsh.Cells(OutputLR, 9).Value = RawDatash.Cells(i, MatchHeaders)
                  
                'Base Site
                MatchHeaders = Application.WorksheetFunction.Match(RefSh.ListObjects("HeaderTable").ListColumns("Appears in Survey Monkey").DataBodyRange(8), RawDatash.Range(RawDatash.Cells(1, 1), RawDatash.Cells(1, Lcol)), 0)
   
                    Select Case RawDatash.Cells(i, MatchHeaders)
                        Case Is = "Other (please specify)"
                                BaseSite = "OTHER"
                        Case Is = "Lon"
                                BaseSite = "London"
                        Case Is = "Der"
                                BaseSite = "Derby"
                        Case Else
                                BaseSite = "OTHER"
                    End Select
                    Outputsh.Cells(OutputLR, 10).Value = BaseSite
                
                'Type
                Outputsh.Cells(OutputLR, 4).Value = myType
            
            '''#####STUCK HERE####'''''
            
            'Get Question Named Range
            QuestionNamedRange = Application.WorksheetFunction.VLookup(myType, QuestionSh.Range("QuestionLookup"), 2, False)
            Set QuestionRange = QuestionSh.Range(QuestionNamedRange)
    
            For rr = 1 To QuestionRange.Rows.Count


                'Section Name
                Outputsh.Cells(OutputLR, 5).Value = QuestionRange.Cells(rr, 1).Offset(, 1).Value
                
                For cc = 3 To QuestionRange.Cells(rr, 1).Offset(, -1) + 2
                    'Loop through questions
                    'Question Name
                    Outputsh.Cells(OutputLR, 11).Value = QuestionRange.Cells(rr, cc).Value
                        
                    'Rating
                    On Error Resume Next
                         MatchHeaders = Application.WorksheetFunction.Match(QuestionRange.Cells(rr, cc).Value, RawDatash.Range(RawDatash.Cells(2, 1), RawDatash.Cells(2, Lcol)), 0)
                        Outputsh.Cells(OutputLR, 12).Value = RawDatash.Cells(i, MatchHeaders)
                    On Error GoTo 0
                Next cc
            Next rr
            
            OutputLR = OutputLR + 1
            
            'Loop through each question and seperate them on its own lineand then move onto next agent and repeat
            'once done go to next sheet and follow same steps
            'Question range depends on which sheet im on
            ''''#################'''''''
        Next i
       End If
    Next ws
End Sub
 
Upvote 0
Any help is appreciated- thank you so much
 
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,755
Members
449,049
Latest member
excelknuckles

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