Solved VBA not producing correct output (1 Viewer)

vba_php

Banned
Joined
Oct 6, 2019
Messages
1,982
Can one of you guys help me spot my error here? I'm pretty sure I'm doing everything right, yet Excel is wrong. What am I not catching? These are my input records:

source_range_values.jpg

this is my code routine:
Code:
Function extract_file_prefix_nameand_print_new_URL()
On Error Resume Next

Dim filePrefixFull As String
Dim filePrefixShort As String
Dim fileprefixprev As String
Dim filePrefix_Transact As String
Dim fileName As String
Dim a1Start As Long
Dim a1End As Long
Dim length As Long
Dim newHref As String
Dim ws As Worksheet
Set ws = ActiveWorkbook.Worksheets("tbl")

Application.ScreenUpdating = False
    Dim r As Range
        For Each r In ws.Range("r65", "r118")
            If Not Left(r, 4) = "<h3>" Then
               
                a1Start = InStr(r, "software/") + 9
                a1End = InStr(r, ".php")
                length = a1End - a1Start
                filePrefixFull = Mid(r, a1Start, length)
                   
                a1Start = InStr(r, "software/") + 9
                a1End = InStr(r, "-")
                length = a1End - a1Start
                filePrefixShort = Mid(r, a1Start, length)
               
                a1Start = InStr(r, "software/") + 9
                a1End = InStr(r, """" & ">")
                length = a1End - a1Start
                fileName = Mid(r, a1Start, length)
               
                    If InStr(filePrefixFull, fileprefixprev) = 0 Or fileprefixprev = "" Then 'new software type reached
                        filePrefix_Transact = filePrefixFull
                    Else
                        filePrefix_Transact = fileprefixprev
                    End If
               
                fileprefixprev = filePrefixFull
                newHref = Replace(r, "software/", "software/" & filePrefix_Transact & "/" & fileName)
                r.Offset(0, -1) = newHref
            End If
        Next r
Application.ScreenUpdating = True
End Function
and this is what I'm getting as a result:

output_range_values.jpg

but what i want as a result is this:

desired_range_values.jpg

Help, anyone? It *is* early in the morning, so I may have messed this one up....
 
Last edited:

vba_php

Banned
Joined
Oct 6, 2019
Messages
1,982
this has been solved. I never did an answer to this issue. I simply typed the HTML code out by hand for all 30 records I was dealing with.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom