Our training courses

Other training resources

Our training venues

Why we are different

Details for EDAC-Charlie

EDAC-Charlie has participated in the following threads:

Added by EDAC-Charlie on 09 Feb 2017 at 15:24

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.

 

Head office

Kingsmoor House

Railway Street

GLOSSOP

SK13 2AA

London

Landmark Offices

99 Bishopsgate

LONDON

EC2M 3XD

Manchester

Holiday Inn

25 Aytoun Street

MANCHESTER

M1 3AE

© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.

End of small page here
Please be aware that our website uses cookies!
I'm OK with this Tell me more ...