Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
547 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Firstly please let me introduce myself, I'm Charlie, I'm new to coding and I have been given a task. The task is to create code to generate discrete part descriptions for every part number our system can generate. I have attached the code that was written to generate the part numbers, I have also attached the code that I am trying to use to generate the descriptions which has compile error type mismatch occurring.
I would very much like to understand the original code and then create new rather than someone writing the code and just accepting that it works, as has happened before, hence the current situation! My first major hurdle is understanding the "i" in for example:
Dim i1 As Long
If Cells(i2, 2) Mod 2 <> 0 And Cells(i4, 4)
and
Next i5
Amongst other areas of the code.
Sub series325()
Dim a As Long
Dim b As Long
Dim c As Long
Dim d As Long
Dim e As Long
Dim i1 As Long
Dim i2 As Long
Dim i3 As Long
Dim i4 As Long
Dim i5 As Long
Dim counter As Long
counter = 1
a = Range("A1").End(xlDown).Row
b = Range("B1").End(xlDown).Row
c = Range("C1").End(xlDown).Row
d = Range("D1").End(xlDown).Row
e = Range("E1").End(xlDown).Row
For i1 = 2 To a
For i2 = 2 To b
For i3 = 2 To c
For i4 = 2 To d
For i5 = 2 To e
If Cells(i2, 2) Mod 2 <> 0 And Cells(i4, 4) Mod 2 = 0 Then GoTo Nexti
If Cells(i2, 2) Mod 2 <> 0 And Cells(i4, 4) = "-2" Then GoTo Nexti
If Cells(i2, 2) > 61 And Cells(i4, 4) = "-1" Then GoTo Nexti
Cells(counter, 10) = Cells(i1, 1) & Cells(i2, 2) & Cells(i3, 3) & Cells(i4, 4) & Cells(i5, 5)
counter = counter + 1
Nexti:
Next i5
Next i4
Next i3
Next i2
Next i1
End Sub
I would like to apply the same method to the descriptions. I was hoping the code below might work, sadly it didn't.
Sub series325PartDescriptionTest()
Dim a As String
Dim b As Long
Dim c As String
Dim d As String
Dim e As String
Dim f As String
Dim g As String
Dim i1 As String
Dim i2 As Long
Dim i3 As String
Dim i4 As String
Dim i5 As String
Dim i6 As String
Dim i7 As String
Dim counter As String
counter = 1
a = Range("A1").End(xlDown).Row
b = Range("B1").End(xlDown).Row
c = Range("C1").End(xlDown).Row
d = Range("D1").End(xlDown).Row
e = Range("E1").End(xlDown).Row
f = Range("F1").End(xlDown).Row
g = Range("G1").End(xlDown).Row
For i1 = 2 To a
For i2 = 2 To b
For i3 = 2 To c
For i4 = 2 To d
For i5 = 2 To e
For i6 = 2 To f
For i7 = 2 To g
If Cells(i2, 2) Mod 2 <> 0 And Cells(i5, 5) Mod 2 = 0 Then GoTo Nexti
If Cells(i2, 2) Mod 2 <> 0 And Cells(i5, 5) = "Double Row formation. " Then GoTo Nexti
Cells(counter, 10) = Cells(i1, 1) & Cells(i2, 2) & Cells(i3, 3) & Cells(i4, 4) & Cells(i5, 5) & Cells(i6, 6) & Cells(i7, 7)
counter = counter + 1
Nexti:
Next i7
Next i6
Next i5
Next i4
Next i3
Next i2
Next i1
End Sub
I am struggling to add the spreadsheets for reference, the formatting falls apart when I use copy & paste.
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.