ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Loop based on number entered in userform (https://www.excelbanter.com/excel-worksheet-functions/242924-loop-based-number-entered-userform.html)

Richhall[_2_]

Loop based on number entered in userform
 
Hi

I have a simple userform with TextBox1, the user enters a value in
here and then based on this value does some work on that row, and i
want it to then move down a row and do the work again for the number
of rows in textbox1. How do I do a loop and count to do this please?

i.e

rowend= Me.TextBox1.Value
set a value for the counter

Start loop

If rowend=counter then end
Else
Do something
ActiveCell.Offset(1, 0).Activate
add 1 to counter
go back to start of loop

Cheers

Rich

Paul C

Loop based on number entered in userform
 
The code would be like this

rowend= Me.TextBox1.Value
set a value for the counter

For A=1 to countervalue
Do something
ActiveCell.Offset(1, 0).Select
Next A

--
If this helps, please remember to click yes.


"Richhall" wrote:

Hi

I have a simple userform with TextBox1, the user enters a value in
here and then based on this value does some work on that row, and i
want it to then move down a row and do the work again for the number
of rows in textbox1. How do I do a loop and count to do this please?

i.e

rowend= Me.TextBox1.Value
set a value for the counter

Start loop

If rowend=counter then end
Else
Do something
ActiveCell.Offset(1, 0).Activate
add 1 to counter
go back to start of loop

Cheers

Rich



All times are GMT +1. The time now is 02:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com