Hi friends I am working on a code that adding odd number from 1 to the number user determines. I did the adding number but I don't know how I should do it for odd number. I hope anybody can help me.
In attachment you can find what I've done.
Hi friends I am working on a code that adding odd number from 1 to the number user determines. I did the adding number but I don't know how I should do it for odd number. I hope anybody can help me.
In attachment you can find what I've done.
Last edited by loloobaloo; 06-23-2022 at 01:13 AM.
Maybe just add a step to your loop:
Sub OddNumber() Dim num As Integer Dim Sum As Long Dim i As Long num = InputBox("Enter your number") Range("A1").Value = num For i = 1 To num Step 2 Sum = Sum + i Next Range("A2").Value = Sum End Sub
Thanks it works.