Looping HELP

GemaDilemma

New Member
Joined
Apr 20, 2013
Messages
6
Hi Guys

I'm relatively new to looping and im looking for some help.

My problem is I want to loop an action based on the value of a cell (that value will change).

Example:

If Sheet 1 Range A1 = 10

Copy selection from Sheet 2

Return to Sheet 1, and paste selection 10 times (based on the value of sheet 1, a1)

Any help I can get with this would be hugely appreciated.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
If you're looking to identify the end of a worksheet, try:

FinalRow = Cells(Rows.Count, 2).End(xlUp).Row

This line finds the last row of data in a spreadsheet.


FinalCol = Cells(1, Columns.Count).End(xlToLeft).Column

This one locates the final column in a spreadsheet.

You want to make sure to pick a row or column with no gaps in data or the line will misidentify the last line of data.

You also want to make sure that you declare FinalCol and FinalRow as variables with a "Dim" statement, "Dim FinalRow as Integer.

Finally you can use the FinalRow or FinalCol in your "For/Next loop as follows:

For FinalRow = ("A1") to FinalRow 'You can pit in a step value here if you want, e.g. Step 2

Next FinalRow

I'm new at all of this, I just wrote a huge report that slings data from a couple different spreadsheets into a third spreadsheet and then e-mails itself to a custom mailing list. I can do in a mouse click what used to take me close to an hour. This stuff is great.
 
Last edited:
Upvote 0
I'm new at all of this, I just wrote a huge report that slings data from a couple different spreadsheets into a third spreadsheet and then e-mails itself to a custom mailing list. I can do in a mouse click what used to take me close to an hour. This stuff is great.

Hay FTM

Thanks for the advice, im semi new to this as well (haven't done in it a looooong time).

Essentially im trying to do the same as what you have describe and what i have done already is dramatically decreased my work load, thanks for you advice :)

G
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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