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!
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

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.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,224
Messages
5,594,915
Members
413,952
Latest member
JGer

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