VBA exits sub as soon as Cell value has changed

Totti

New Member
Joined
Apr 6, 2013
Messages
3
Hi, i am trying to using a Sub to update the value of a cell & then proceed to do something else.

Here's an example of the code piece:

For k = 2 to 10

ActiveSheet.Cells(k,3).Value = 10

Next k

VBA seems to quit after it has changed the value for k = 2. Why is that?

Thanks for your help!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Jerry Sullivan

MrExcel MVP
Joined
Mar 18, 2010
Messages
8,787
Hi Totti and Welcome to the Board,

I'm not seeing anything in that For...Next block that should cause VBA to exit the Sub.

Is there anything special about that range of cells, such as merged cells, locked cells on a protected sheet, data validation, conditional formatting, pivotTable occupying those cells?

Could you post the rest of your code?
Does the code stop with an error in the debugger or merely finish executing after changing Cell C2 without changing the cells in Range C3:C10?
 

Totti

New Member
Joined
Apr 6, 2013
Messages
3
Thanks Jerry!

No, nothing special about the cells. I will check again. I have save the workbook in the xlsm format. My code is just that. It changes Cell C2 & exits without changing rest of the cells!..very weird.

On a separate note, what happens if they are part of data validation?
 

Totti

New Member
Joined
Apr 6, 2013
Messages
3
I think i might have found the source of the problem. I had to enable iterative calculations in the excel options. That fixed it. Thanks for the primer.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,898
Messages
5,834,295
Members
430,274
Latest member
TME1993

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