Forum Discussion
hrh_dash
Jul 13, 2022Iron Contributor
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...
- Jul 13, 2022
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
PeterBartholomew1
Jul 13, 2022Silver Contributor
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 Subhrh_dash
Jul 14, 2022Iron Contributor
thanks for the help! it works like a charm!