anilsharaf
New Member
- Joined
- Apr 8, 2014
- Messages
- 43
- Office Version
- 2007
- Platform
- Windows
I have this data
And Output data wanted first putting it in an array of NewTable (1 to 357, 1 to 7) and then to sheet named RollNos Like this
Nominal Sheet No increses 1 after 5 Roll Nos. ( 1 Nominal Roll contains 5 Roll Nos)
There should be a better code to do this. So please do not base the code on my code. It is based on superficial knowledge. I wanted to do it myself but I failed. Thanks in Advance.
Sitting Board_V1 Principle and Module InProcess.xlsm | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | |||
1 | Sn_Final_according_to_Check_List | RN_from | RN_To | Medium | Type | Sort3_Center_Number_ | School_Name_Hss_2024 | Total_Students | ||
2 | 1 | 2243203786 | 2243203830 | Hindi | Regular | 321042 | Barpali | 45 | ||
3 | 2 | 2243203831 | 2243203899 | Hindi | Regular | 321044 | Boys | 69 | ||
4 | 3 | 2243203946 | 2243203981 | Hindi | Regular | 321070 | Madwa | 36 | ||
5 | 4 | 2243203982 | 2243204046 | Hindi | Regular | 321224 | Pithampur | 65 | ||
6 | 5 | 2243204115 | 2243204139 | Hindi | Regular | 322292 | DVM | 25 | ||
7 | 6 | 2243280021 | 2243280021 | Hindi | Div Improve | 321044 | Boys | 01 | ||
8 | 7 | 2243299002 | 2243299002 | Hindi | Div Improve | 321070 | Madwa | 01 | ||
9 | 8 | 2243203900 | 2243203945 | English | Regular | 321044 | Atmanand | 46 | ||
10 | 9 | 2243204047 | 2243204114 | English | Regular | 322071 | Lions | 68 | ||
11 | 10 | 2243280022 | 2243280022 | English | Div Improve | 322071 | Lions | 01 | ||
12 | Tot | 357 | ||||||||
AllotedRollNos |
And Output data wanted first putting it in an array of NewTable (1 to 357, 1 to 7) and then to sheet named RollNos Like this
Sitting Board_V1 Principle and Module InProcess.xlsm | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
1 | Sort 3 Sn | Roll No | Medium | Type RegOrDivImprove | Center No | School Name | Nominal Sheet No | ||
2 | 1 | 3786 | Hindi | Regular | 321042 | Barpali | 1 | ||
3 | 2 | 3787 | Hindi | Regular | 321043 | Barpali | 1 | ||
4 | 3 | 3788 | Hindi | Regular | 321044 | Barpali | 1 | ||
5 | 4 | 3789 | Hindi | Regular | 321045 | Barpali | 1 | ||
6 | 5 | 3790 | Hindi | Regular | 321046 | Barpali | 1 | ||
7 | 6 | 3791 | Hindi | Regular | 321047 | Barpali | 2 | ||
8 | 7 | 3792 | Hindi | Regular | 321048 | Barpali | 2 | ||
9 | 8 | 3793 | Hindi | Regular | 321049 | Barpali | 2 | ||
10 | 9 | 3794 | Hindi | Regular | 321050 | Barpali | 2 | ||
11 | 10 | 3795 | Hindi | Regular | 321051 | Barpali | 2 | ||
12 | 11 | 3796 | Hindi | Regular | 321052 | Barpali | 3 | ||
13 | 12 | 3797 | Hindi | Regular | 321053 | Barpali | 3 | ||
14 | 13 | 3798 | Hindi | Regular | 321054 | Barpali | 3 | ||
15 | 14 | 3799 | Hindi | Regular | 321055 | Barpali | 3 | ||
16 | 15 | 3800 | Hindi | Regular | 321056 | Barpali | 3 | ||
17 | 16 | 3801 | Hindi | Regular | 321057 | Barpali | 4 | ||
18 | 17 | 3802 | Hindi | Regular | 321057 | Barpali | 4 | ||
RollNos |
Nominal Sheet No increses 1 after 5 Roll Nos. ( 1 Nominal Roll contains 5 Roll Nos)
VBA Code:
Option Base 1
Sub CreateRollNumberArray_notReady()
Dim RollNumbers()
Dim Medium() As Variant
Dim i, ir As Long
Dim RowCounter As Long
' Define the range for Roll Numbers and Medium
'Dim RollNumberRange() As Range
Dim MediumRange As Range
RollNumberRange = Worksheets("AllotedRollNos").Range("B2:C2") ' Adjust the range as needed
Set MediumRange = Worksheets("AllotedRollNos").Range("D2") ' Medium is in D2
' Initialize the array size based on the number of Roll Numbers
'ReDim RollNumbers(1 To RollNumberRange.Columns.Count)
'ReDim Medium(1 To RollNumberRange.Columns.Count)
' Expand RollNumbers
q = LBound(RollNumberRange, 2) 'column
q2 = UBound(RollNumberRange, 2)
'8888888888888888888
startNum = RollNumberRange(1, 1)
'Debug.Print startNum
endNum = RollNumberRange(1, 1 + 1)
'Debug.Print endNum
Tot = (endNum - startNum) + 1
'ir = 1
For i = startNum To endNum
ir = ir + 1
'888888888888888888888
ReDim Preserve RollNumbers(ir)
RollNumbers(ir) = i
ReDim Preserve Medium(ir)
Medium(ir) = MediumRange.Value
Next i
' Now you have the Roll Numbers and Medium in separate arrays
' You can access them individually or use them as needed
' Example: Print Roll Numbers and Medium
For i = 1 To UBound(RollNumbers)
Debug.Print "Roll Number: " & RollNumbers(i) & ", Medium: " & Medium(i)
Next i
End Sub