Link to home
Start Free TrialLog in
Avatar of samprg
samprg

asked on

Loop

Hello,
I need "loop" in Excel 2010 , please see in below. Thanks
Cell   A    -   B  - Result in C
       2011    3        2011&2010&2009
Avatar of etech0
etech0
Flag of United States of America image

sub loopmacro()
dim x as integer
dim result as string
for x = 1 to range("B1").value
    result = result & range("A1").value - (x - 1)
next x

End sub
whoops! left out a line...

sub loopmacro()
dim x as integer
dim result as string
for x = 1 to range("B1").value
    result = result & range("A1").value - (x - 1)
    range("C1").value = result
next x

End sub


if you want this to happen to the whole column, let me know and I'll adjust the macro.
ASKER CERTIFIED SOLUTION
Avatar of kgerb
kgerb
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of samprg
samprg

ASKER

I think this micro, I do not want to add macro please
so you don't want vba?  You want a formula?
I'm sorry, I didn't understand that. Can you rephrase?
What's the highest possible value in row b?
Avatar of samprg

ASKER

Yes, I want a formula
Avatar of samprg

ASKER

etech0:
In Column B (3) is how many times for loop
It will always be 3?
Avatar of samprg

ASKER

Yes
in c3 type:
=a1&"&"&a1-1&"&"&a1-2

then copy down the column
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of samprg

ASKER

Thanks