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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

StephenCrump

MrExcel MVP
Joined
Sep 18, 2013
Messages
4,124
Office Version
  1. 365
Platform
  1. Windows
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?
 

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,419
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Is Interface a variable that represents a worksheet or what?
 

Watch MrExcel Video

Forum statistics

Threads
1,129,551
Messages
5,636,965
Members
416,952
Latest member
prakashkumar

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
Top