divide a specified value by a specified number of months

User avatar
HansV
Administrator
Posts: 78238
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: divide a specified value by a specified number of months

Post by HansV »

You might run this macro:

Code: Select all

Sub CopyAsValues()
    Dim m As Long
    With Worksheets("Main File")
        m = .Range("A" & .Rows.Count).End(xlUp).Row
        Worksheets("Outputs").Range("A8:C" & m + 6).Value = .Range("C2:E" & m).Value
    End With
End Sub
Best wishes,
Hans

luis gaspper
StarLounger
Posts: 68
Joined: 03 Aug 2020, 05:23

Re: divide a specified value by a specified number of months

Post by luis gaspper »

Thanks again Mr. Hans for all the great help you offered
Best Regards

luis gaspper
StarLounger
Posts: 68
Joined: 03 Aug 2020, 05:23

Re: divide a specified value by a specified number of months

Post by luis gaspper »

Mr. Hans, Once again I am very sorry
I would like to make one slight change if possible.
I'd like to replace the result to $ 500 instead of blank

Code: Select all

Function FirstGroup(Condition As String, TheDate As Date) As Variant
    FirstGroup = CVErr(xlErrNA)
    Application.Volatile
    On Error GoTo NiceExit
    
    If Month(TheDate) = 1 And Condition = "OK" Then
        FirstGroup = 1000
    Else
        FirstGroup = vbNullString
    End If
NiceExit:
End Function
I mean , Other than January the result is $500.
Once again, thank you for you help.

User avatar
HansV
Administrator
Posts: 78238
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: divide a specified value by a specified number of months

Post by HansV »

Isn't that obvious? Change

FirstGroup = vbNullString

to

FirstGroup = 500
Best wishes,
Hans

luis gaspper
StarLounger
Posts: 68
Joined: 03 Aug 2020, 05:23

Re: divide a specified value by a specified number of months

Post by luis gaspper »

Again my sincere thanks for taking an interest in my problem.