Question about my Macro

rwmill9716

Active Member
Joined
May 20, 2006
Messages
493
Office Version
  1. 2013
Platform
  1. Windows
This code takes the value in Cell N2 and writes it to Column S after the last value in that column. I've put a loop into the code to try to get 1,000 values in column S, but what's happening is that it doesn't stop at 1,000 it just keeps pouring data into Column S. I need code that will limit the data in column S to 1,000 values.

Thanks,

Ric Miller

<Code>Private Sub Worksheet_Calculate()
Application.EnableEvents = False
N = 0
Do Until N = 1000
N = N + 1
Range("S" & Rows.Count).End(xlUp).Offset(1) = Range("N2").Value
Application.EnableEvents = True
Loop
End Sub
</Code>
 
I do mean the F9 key, and I don't have a script assigned to it. I've gone into the options/formula page of Excel and changed it to manual.
 
Upvote 0

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
This is your code but instead of the second time running it going from 1000 to 2000 it will go from 1 to 1000 again


Rich (BB code):
Private Sub Worksheet_Calculate()
Application.EnableEvents = False
N = 0
Do Until N = 1000
N = N + 1
Range("S" & n).offset(1) = Range("N2").Value
Application.EnableEvents = True
Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,185
Members
449,071
Latest member
cdnMech

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