Creatiing a flowchart from VBA code

Donae

New Member
Joined
Jul 14, 2016
Messages
4
I have no idea how to convert it to a flowchart. I tried looking it up with no such luck. Below is a sample of the code that I need to convert to a flowchart. Thank you!

Code:
Public Sub mainSub()
    'Dim path As String
    
    'Workbooks("try3.xlsm").Activate
    
    'path = ActiveWorkbook.path
    
    'ChDir path
    
    'Set NewBook = Workbooks.Add
    
    'Workbooks.Add
    
    'ActiveWorkbook.SaveAs Filename:="output111" & ".xls"
    
    CreateWorkBookAndAddSheets (3)
    CreateWorkBookAndAddSheets (4)
        
    'NewBook.Close SaveChanges:=True
    MsgBox "Done!"
End Sub
Private Sub CreateWorkBookAndAddSheets(ByVal repeatingNum As Integer)
            
    Dim rowCount As Long
    
    Dim sourceDataSheet As Worksheet
    
    Set sourceDataSheet = ActiveWorkbook.Sheets("data")
    
    rowCount = sourceDataSheet.Range("A" & Rows.Count).End(xlUp).Row
    Dim resultSheet As Worksheet
    
    Set resultSheet = ActiveWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
    
    resultSheet.Name = "Data for All repeating " & repeatingNum
    Dim i As Long
    Dim j As Long
    Dim k As Long
    Dim first As Boolean
    
    k = -1
    j = 0
    first = True
    
    For i = 1 To rowCount
        If sourceDataSheet.Range("A1").Offset(i, 0).Value = repeatingNum And (repeatingNum = 3 Or repeatingNum = 4) Then
            
            If first = True Then
                k = k + 1
                j = 0
                first = False
            End If
            
            resultSheet.Range("A1").Offset(j, k).Value = sourceDataSheet.Range("B1").Offset(i, 0).Value
            j = j + 1
        Else
            first = True
        End If
    Next i
    
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top