View attachment 71987
Just read the "headline" What I asked for previously is not needed. My apologies.
"Formula to calculate the inches given tank size, length, and diameter and gallons per inch"
Make sure to check results as this is from an old workbook that I have never used and also never checked for accuracy.
Never heard back from the OP that it was presented to if it was right or not.
Set up your sheet as in picture.
Add two "Form Control" Buttons as shown in picture (or wherever).
Copy both codes and paste in a regular module (Module1 maybe).
This code works on the "Make List" Button.
Code:
Sub Make_List_Inch_Gal()
Dim a As Long, i As Long, j As Long
a = WorksheetFunction.Ceiling(Range("K1"), 5) \ 5 '<--- Backward slash to make result an integer in case there are decimals in cell K1
Application.ScreenUpdating = False
With Range("A4:A" & 3 + Range("K1").Value \ 1) '<--- Backward slash to make result an integer in case there are decimals in cell K1
.Formula = "=Row()-3"
.Value = .Value
.Offset(, 1).Formula = "=(R1C7*(R1C11/2)^2)*(ACOS(1-(2*(RC1))/R1C11)-(SIN(ACOS(1-(2*(RC1))/R1C11))*COS(ACOS(1-(2*(RC1))/R1C11))))*0.004329"
.Offset(, 1).Value = .Offset(, 1).Value
.Offset(, 1).NumberFormat = "0.000"
End With
j = 4 + a
For i = 4 To 13 Step 3
Range(Cells(j, 1), Cells(j + a - 1, 1)).Resize(, 2).Copy Cells(4, i)
j = j + a
Next i
Range("A" & a + 4 & ":B" & Range("K1").Value \ 1 + 4).EntireRow.Delete Shift:=xlUp '<--- Backward slash to make result an integer in case there are decimals in cell K1
ActiveSheet.PageSetup.PrintArea = Range("A1").CurrentRegion.Resize(, 14).Address
Application.ScreenUpdating = True
End Sub
This code works on the "Clear List" Button.
Code:
Sub Undo_Inch_Gallons()
Range("A1:N" & Cells(Rows.Count, "A").End(xlUp).Row).Offset(3).Delete Shift:=xlUp
End Sub