Trying to Run a Loop inside a For Next Loop - Wont Loop

EL_SB

New Member
Joined
Mar 19, 2016
Messages
17
In one For loop not shown in the code I have found a cell (I, "T") And I've given it a value Wash2. Now the Column T is a list of times. For every row in column T after I, I want to add 15 mins to the previous time. I've set up a new counter as J which is I + 1, and want to loop the the end of the column which is the variable F15Last. Unfortunately I can only get it to execute once and not loop until F15Last. Any ideas?

Code:
Interface.Cells(I, "T").Value = Wash2
    J = I + 1
    Do While J <= F15Last


        Ref3 = Interface.Cells(J, "T")
'        Ref3 = Ref3 - Int(Ref3)
        CheckNow10 = Interface.Cells(J, "AA")
       CheckNow10.Value = Ref3
'        If Int(Ref4) - Int(Ref3) > 0 Then 'If time is in a new day need to change the day number
'        Interface.Cells(J, "S").Value = Interface.Cells(J, "S").Value + 1
'        Else
'        End If


        'Interface.Cells(J, "T").Value = TimeAdd + Ref3
        J = J + 1
    Loop
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
It's difficult to diagnose a problem from an incomplete code snippet like this. However, I notice that your code has these two lines:

Code:
CheckNow10 = Interface.Cells(J, "AA")
CheckNow10.Value = Ref3

The first line assigns a value to CheckNow10, i.e. the default .Value property of Interface.Cells(J, "AA").
Which means that your code should error on the next line as CheckNow10.Value won't be a meaningful reference.

Alternatively, if you have declared CheckNow10 as a range variable, your code will error on the first line, because you need to Set CheckNow10 = Interface.Cells(J, "AA"))

If you're not getting an error message, you either have On Error Resume Next further up in your code (which is a dangerous practice) or an error handler that your code is jumping to?
 
Upvote 0
Is Interface a variable that represents a worksheet or what?
 
Upvote 0

Forum statistics

Threads
1,214,391
Messages
6,119,249
Members
448,879
Latest member
oksanana

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