Data allocation looping limited to 31 lines only.

erkkyy

New Member
Joined
May 4, 2016
Messages
4
I'm having a problem with my code that allocates the user input data. The looping works fine but it is limited to 31 lines only.

Here's the code:

Code:
Sub HYD_HYDMNL_TIX()

Dim MNLCounter As Double, HYDCounter As Double, MNL As Double, HYD As Double
Dim nextrow As Double


MNL = ActiveSheet.Range("B4").Value + 6
HYD = ActiveSheet.Range("F4").Value + 6
nextrow = ActiveSheet.Range("O4").Value + 4
MNLCounter = 4
HYDCounter = 4


For HYDCounter = 4 To HYD

 ActiveSheet.Range("Q" & nextrow).Value = ActiveSheet.Range("H" & HYDCounter).Value
 nextrow = ActiveSheet.Range("O4").Value + 4
 ActiveSheet.Range("Q" & nextrow).Value = ActiveSheet.Range("D" & MNLCounter).Value

 MNLCounter = MNLCounter + 1

 nextrow = ActiveSheet.Range("O4").Value + 4
 
Next HYDCounter

End Sub

Have tried changing the value of
Code:
For HYDCounter = 4 To HYD
to
Code:
For HYDCounter = 4 To 1000
but still does not work properly and it still limited to 31 lines only.

Appreciate your help.
 
Does cell O4 on the active sheet have a formula in it? If yes, what's the formula? If no, then your value of nextrow is static - is that what you intended?
 
Last edited:
Upvote 0
Same formula with cells
Code:
B4 & F4
The value of HYD is fixed when you start looping. nextrow changes during the loop only if the cells in col Q you are writing to are empty before the write. Otherwise nextrow is static. I'm not clear on what you want your macro to accomplish, but if you explain what you want to happen, maybe there's a better way.
 
Upvote 0

Forum statistics

Threads
1,226,812
Messages
6,193,116
Members
453,777
Latest member
Miceal Powell

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