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

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
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?
 
Upvote 0
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?
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,576
Members
448,972
Latest member
Shantanu2024

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