VBA loop down x number of cells, move to next column and loop again

alex_santaana

New Member
Joined
May 4, 2017
Messages
1
Good Morning Everyone!

I'm about 4 months into learning VBA so I'm still a beginner. I am trying to write a code and I'll do my best to explain what I'm trying to do. I have a worksheet with multiple columns of financial data going down the columns (In this case columns C,E,G,I,K....). Next to each column of financial data is a blank space where I will calculate the value to the left as a percentage of the overall values of that column. Once that is done, I want the loop to go two columns over and perform the actions again. This needs to be dynamic as reports have different number of rows and columns.

My logic is to create a loop within a loop that is able to start at the first occurrence of financial data in the first column, calculate each row of data until the final row at which point the inner loop would end triggering the outer loop to move to the next column and perform the inner loop again.

I am having a lot of trouble finding an answer for how to do this, specifically how to do a for loop within a for loop. I keep getting errors on my "Next" statement saying there is no "For". Any and all help will be greatly appreciated. Thanks everyone.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hi Alex,

Welcome to the MrExcel Forum.

Perhaps you could post your code so that we can see where you're at and why the code is throwing the error.
 
Upvote 0
hi

often, NEXT WITHOUT FOR is where you may have WITH without ENDWITH or IF without ENDIF.

But a suggested above, if you could share your code would help look into the problem.

Dave
 
Upvote 0
alex_santaana,

Can we see what your current macro code looks like?


When posting VBA code, please use Code Tags - like this:

[code=rich]

Paste your code here.

[/code]
 
Upvote 0

Forum statistics

Threads
1,223,887
Messages
6,175,199
Members
452,617
Latest member
Narendra Babu D

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