VBABeginer_Chappers
New Member
- Joined
- Mar 8, 2018
- Messages
- 10
Hi
I have a Table B3:AD6 on multiple sheets (YYYY-Registration). Cell B1 shows the location of the vehicle.
I want to create a table on Sheet (Chart Output) that is the sum of selected tables from other sheets, which sheets are used depends upon the year selected and the Location selected via an InputBox.
The registrations are all listed on sheet (To Hide) C2:C26.
I started to use arrays but I only started using VBA last year so got somewhat confused with loops.
This is as far as I got
Sub Create_Table()
Dim Aircraft_Array(2 To 26)
Dim Table_Array(27, 2)
Dim Select_Year As String
Dim Sum_Array(27, 2)
Dim Select_Location As String
Select_Year = InputBox("Enter the Required year", "What is the Required Year?")
'Select_Location = InputBox("Enter the Required Location", "What is the Required Location?")
If Select_Year = vbNullString Then Exit Sub
'If Select_Location = vbNullString Then Exit Sub
For i = 2 To 26
Aircraft_Array(i) = Sheets("To Hide").Range("C" & i)
For X = 0 To 27
' Starts The Outer Loop
For Y = 0 To 2
' Starts the Inner Loop
Table_Array(X, Y) = Sheets(Select_Year & " " & Aircraft_Array(i)).Range(Cells(X + 3 & Y + 4), Cells(X + 6 & Y + 30))
Next Y
Next X
'MsgBox (Table_Array(2, 2))
Next i
End Sub
Any help would be appreciated.
Chappers
I have a Table B3:AD6 on multiple sheets (YYYY-Registration). Cell B1 shows the location of the vehicle.
I want to create a table on Sheet (Chart Output) that is the sum of selected tables from other sheets, which sheets are used depends upon the year selected and the Location selected via an InputBox.
The registrations are all listed on sheet (To Hide) C2:C26.
I started to use arrays but I only started using VBA last year so got somewhat confused with loops.
This is as far as I got
Sub Create_Table()
Dim Aircraft_Array(2 To 26)
Dim Table_Array(27, 2)
Dim Select_Year As String
Dim Sum_Array(27, 2)
Dim Select_Location As String
Select_Year = InputBox("Enter the Required year", "What is the Required Year?")
'Select_Location = InputBox("Enter the Required Location", "What is the Required Location?")
If Select_Year = vbNullString Then Exit Sub
'If Select_Location = vbNullString Then Exit Sub
For i = 2 To 26
Aircraft_Array(i) = Sheets("To Hide").Range("C" & i)
For X = 0 To 27
' Starts The Outer Loop
For Y = 0 To 2
' Starts the Inner Loop
Table_Array(X, Y) = Sheets(Select_Year & " " & Aircraft_Array(i)).Range(Cells(X + 3 & Y + 4), Cells(X + 6 & Y + 30))
Next Y
Next X
'MsgBox (Table_Array(2, 2))
Next i
End Sub
Any help would be appreciated.
Chappers