ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automatic Config Tool Question (https://www.excelbanter.com/excel-programming/356260-automatic-config-tool-question.html)

Crumb

Automatic Config Tool Question
 
Can anyone help me with this configuration question?

I am trying to build a tool that allows user to input any number and
the results are broken down into units of 5,10,20, 50, 100 and 200
starting at the highest were possible and working its way down. the
Number of units should always exceed the input.

Example.

User enters 67

Return should be 50x1, 10x2

The units will be in cells A1, A2 and so on and I am looking for the
return to be entered into B1 B2 .....


Can anyone help with this?

Many Thanks

Ian


Tom Ogilvy

Automatic Config Tool Question
 
Assume the highest number is in A1 and descending in order from there

Sub ABC()
Dim v As Long, i As Long
v = InputBox("Enter Number")
i = 1
Do While Not IsEmpty(Cells(i, 1))
cnt = v \ Cells(i, 1)
Cells(i, 2) = cnt
v = v Mod Cells(i, 1)
i = i + 1
Loop
If v < 0 Then
Cells(i - 1, 2) = Cells(i - 1, 2) + 1
End If
End Sub

Lightly tested.

--
Regards,
Tom Ogilvy



"Crumb" wrote in message
oups.com...
Can anyone help me with this configuration question?

I am trying to build a tool that allows user to input any number and
the results are broken down into units of 5,10,20, 50, 100 and 200
starting at the highest were possible and working its way down. the
Number of units should always exceed the input.

Example.

User enters 67

Return should be 50x1, 10x2

The units will be in cells A1, A2 and so on and I am looking for the
return to be entered into B1 B2 .....


Can anyone help with this?

Many Thanks

Ian




Crumb

Automatic Config Tool Question
 
I want to use a cell value and not a input box for the users value, How
do I do this?

Thanks


Tom Ogilvy

Automatic Config Tool Question
 
Sub ABC()
Dim v As Long, i As Long
v = Range("M6") '<== replace with actual cell address
i = 1
Do While Not IsEmpty(Cells(i, 1))
cnt = v \ Cells(i, 1)
Cells(i, 2) = cnt
v = v Mod Cells(i, 1)
i = i + 1
Loop
If v < 0 Then
Cells(i - 1, 2) = Cells(i - 1, 2) + 1
End If
End Sub

--
Regards,
Tom Ogilvy

"Crumb" wrote in message
ps.com...
I want to use a cell value and not a input box for the users value, How
do I do this?

Thanks





All times are GMT +1. The time now is 07:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com