Loop the Code untill cetain value exceeds

Nayasoch

Board Regular
Joined
Sep 9, 2016
Messages
73
Hello Everyone ,

I have this code

Code:
Worksheets("Graph5").Range("G1").FormulaR1C1 = "0.01"
    Worksheets("Graph5").Range("I1:J1").Select
    Selection.Copy
    Worksheets("Graph5").Range("L1:M1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

Now I need to replace o.o1 with 0.02 upto 0.99 and such that Range("I1:J1") and Range("G1") remains constant but Range("L1:M1") changes accordingly. For example...if it is 0.01, then Range("L1:M1") and when it is 0.02, it need to be Range ("L2:M2") upto ("L100:M100") as Range("G1") goes from 0.01 to 0.99.

Any help would be Highly appreciated.;);)
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
You might consider a For/Next loop...

Code:
Dim i As Double, j As Long
j = 1
For i = 0.01 To 0.99 Step 0.01
    Worksheets("Graph5").Range("G1").FormulaR1C1 = i
        Worksheets("Graph5").Range("I1:J1").Select
        Selection.Copy
        Worksheets("Graph5").Range("L" & j & ":M" & j).Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    j = j + 1
Next i

Cheers,

tonyyy
 
Upvote 0
Thanks tonyy...It made my day and saved me a several hours.............It works perfectly and smoothly.:)
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top