Catyclaire85
New Member
- Joined
- Nov 23, 2021
- Messages
- 20
- Office Version
- 2016
- Platform
- Windows
Hi
I hope you can help me. I have a huge data set, which I have created an anonymised, very small, view of for demonstration purposes. With this data set I need to build something so that based on the past data, and with new data every week, I can pull out the relevant data to me.
I currently have:
Sheet1 - the raw data
sheet2 - the relevant data needed headers
sheet3 - the list of relevant and irrelevant appointment types
I need to be able to find all the appointment types in the raw data from the relevant list and copy this data to sheet2 whilst:
a. converting the date from split across 4 columns into 1 column in recognisable date format. The current format is not able to be just combined and recognised. I can do this with a formula but the data set I need to work with originally is around 900,000 rows of data that I am splitting into batches so it can be handled.
b. identifying any appointment types not on either the relevant or irrelevant lists to be added in
I have been trying to do this but the best I have been able to achieve will find the first row with a specific appointment type in after I have amended the date with the formula.
Code I have used is below:
Please can anyone suggest another approach as I have not been able to find anything more suitable and adaptable with my searches on this forum and others.
Images of the Tables as they are attached.
I hope you can help me. I have a huge data set, which I have created an anonymised, very small, view of for demonstration purposes. With this data set I need to build something so that based on the past data, and with new data every week, I can pull out the relevant data to me.
I currently have:
Sheet1 - the raw data
sheet2 - the relevant data needed headers
sheet3 - the list of relevant and irrelevant appointment types
I need to be able to find all the appointment types in the raw data from the relevant list and copy this data to sheet2 whilst:
a. converting the date from split across 4 columns into 1 column in recognisable date format. The current format is not able to be just combined and recognised. I can do this with a formula but the data set I need to work with originally is around 900,000 rows of data that I am splitting into batches so it can be handled.
b. identifying any appointment types not on either the relevant or irrelevant lists to be added in
I have been trying to do this but the best I have been able to achieve will find the first row with a specific appointment type in after I have amended the date with the formula.
Code I have used is below:
VBA Code:
Sub IncAppts()
Dim Output(1 To 30000, 1 To 7)
Dim ArraytoLookup As Variant
Dim ValtoLookup As Variant
Dim Rowfound As Integer
Dim AllAppts As Variant
Dim RowCounter As Integer
Dim ApptDate As String
Dim ApptInput As Variant
AllAppts = WorksheetFunction.CountA(Sheet1.Range("D1:D30000"))
ApptInput = Sheet1.Range("A1:K30000")
NextRow = WorksheetFunction.CountA(Sheet2.Range("D1:D300000"))
NextRow = NextRow + 1
For RowCounter = 1 To AllAppts
ArraytoLookup = Sheet1.Range("D1:D30000")
ValtoLookup = Sheet3.Range("B1")
Rowfound = IsInArrayNumbers(ArraytoLookup, ValtoLookup)
If Rowfound > 0 Then
Output(1, 1) = ApptInput(Rowfound, 1)
Output(1, 2) = ApptInput(Rowfound, 2)
Output(1, 3) = ApptInput(Rowfound, 3)
Output(1, 4) = ApptInput(Rowfound, 4)
Output(1, 5) = ApptInput(Rowfound, 11)
Output(1, 6) = ApptInput(Rowfound, 9)
Output(1, 7) = ApptInput(Rowfound, 10)
End If
Next RowCounter
Sheet2.Range("A" & NextRow & ":G" & (NextRow + 29999)) = Output
End Sub
Function IsInArrayNumbers(arr As Variant, valueToFind) As Variant
IsInArrayNumbers = 1
IsInArrayNumbers = Application.Match(valueToFind, arr, 0)
If IsError(IsInArrayNumbers) Then IsInArrayNumbers = -1
End Function
Please can anyone suggest another approach as I have not been able to find anything more suitable and adaptable with my searches on this forum and others.
Images of the Tables as they are attached.