Forum Discussion

hrh_dash's avatar
hrh_dash
Iron Contributor
Jul 13, 2022
Solved

Macro to display the data based on the info entered into the dialog boxes

I would like to create a macro with dialog boxes requesting users for the following information - number of vendors - names of vendors - respective vendor amount   Therefore, if the users were t...
  • PeterBartholomew1's avatar
    Jul 13, 2022

    hrh_dash 

    This offers some minimal corrections

    Sub userdata()
    
    Dim FileName As String
    Dim CountVendor As Integer
    Dim Count As Integer
    'Dim sum1 As Long
    'Dim sum2 As Long
    
    Dim ws As Worksheet
    
    Set ws = Sheet1
    
    FileName = InputBox("Please indicate this file name")
    
    ws.Range("B1") = FileName
    
    CountVendor = 0
    CountVendor = InputBox("Please indicate number of vendors")
    
    For Count = 1 To CountVendor
    
    ws.Range("A" & Count + 2) = InputBox("Name of Vendor " & Count)
    
    ws.Range("B" & Count + 2) = InputBox("Please indicate Vendor " & Count & " Amount")
    
    
    Next Count
    
    
    ws.Range("A" & CountVendor + 3).Value = "Total"
    
    With ws.Range("B" & CountVendor + 3)
            .NumberFormat = "#,##0.00"
            .Formula = "=SUM(B3:B" & CountVendor + 2 & ")"
            .Value = .Value
    End With
        
    End Sub