jeudi 8 novembre 2018

Having trouble understanding the logic behind "If..Then Go To" in VBA Excel

I am reading through some VBA code written by someone else and I can't understand the logic behind it:

Sheets("IC View").Select
RowCount = Cells(Rows.Count, 1).End(xlUp).Row

If RowCount <= 9 Then GoTo skipNoChange

    'Sheets("IC View").Select
    Range("A1:BG1").EntireColumn.Hidden = False
    Range(Cells(10, "A"), Cells(LastRowIC, 
   "BG")).SpecialCells(xlCellTypeVisible).Copy

    Worksheets("IC Log").Select
    nextRowLog = Cells(Rows.Count, 1).End(xlUp).Row + 1
    Range("A" & nextRowLog).PasteSpecial xlPasteValues
    Application.CutCopyMode = False

skipNoChange:

Sheets("IC View").Select
zeroCheck = 2   'start at column 3
    Do While Cells(9, zeroCheck + 1).value <> "Checked_By"
        If Cells(9, zeroCheck + 1).value = "" Then Columns(zeroCheck + 
        1).EntireColumn.Hidden = True
        If Cells(9, zeroCheck + 1).value <> "" Then Columns(zeroCheck + 
        1).EntireColumn.Hidden = False
        zeroCheck = zeroCheck + 1
     Loop

'==================================
Call checkFreesaleChanges

So if the row count is less than or equal to 9 then i understand it needs to go 'SkipNoChange', but where does 'SkipNoChange end? Does it end at 'zeroCheck ... Loop' and then moves on to 'Call checkFreesaleChanges'?

What happens if the row count is greater than 9? Does it continue with the code but doesn't run the bit between 'skipNoChange: ...Loop' but does run CallcheckFreesaleChanges onwards?

Aucun commentaire:

Enregistrer un commentaire