chanmeggichan
New Member
- Joined
- Nov 30, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hi, I'm a newbie and self-learner so please bear with me.
So, Im trying to run a code that allows me to first copy and paste 2 input cells into another 2 cells, subsequently copying and pasting another range of cells into a Worksheet called "Year". This loop will continue until the dimension i meets the cut-off point.
Hence, I started with doing a "do until" loop.
However, this do until loop didn't work as it got stuck at the very first line (I assume that it was stuck there because there was a yellow arrow beside the code and an error message popped out which says "Invalid use of property")
As this couldn't work, I tried For Next loop. But it couldn't give me the correct result too.
I was sure that the Do Until loop is correct but Im not too sure now that the "DO Until" loop could not even work.
Please if anyone could just point me in the right direction and let me know why the loop does not work. Thank you and much appreciated~
So, Im trying to run a code that allows me to first copy and paste 2 input cells into another 2 cells, subsequently copying and pasting another range of cells into a Worksheet called "Year". This loop will continue until the dimension i meets the cut-off point.
Hence, I started with doing a "do until" loop.
However, this do until loop didn't work as it got stuck at the very first line (I assume that it was stuck there because there was a yellow arrow beside the code and an error message popped out which says "Invalid use of property")
Excel Formula:
Sub Test4()
Dim i As Integer
i = 0
Do While i <= (B58 * 4) - 1
Range("D58").Copy Range("B15")
Range("B59").Copy Range("B16")
Range("B14:B55").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Year").Select
Range("B2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
i = i + 1
Loop
End Sub
As this couldn't work, I tried For Next loop. But it couldn't give me the correct result too.
VBA Code:
Sub TEST()
Dim i As Integer
i = 0 'Quarter
For i = i To ((Range("B58")) * 4) - 1
Range("D58").Copy Range("B15")
Range("B59").Copy Range("B16")
Range("B15:B56").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Year").Select
Range("B2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
i = i + 1
Next
End Sub
I was sure that the Do Until loop is correct but Im not too sure now that the "DO Until" loop could not even work.
Please if anyone could just point me in the right direction and let me know why the loop does not work. Thank you and much appreciated~