Loop Formula Across Columns

suremac

New Member
Joined
Jan 27, 2014
Messages
49
Greetings,

I'd like to loop a formula across columns and have it stop when it gets to the last column that I have defined. Here is the code:

Code:
Sub LoopAcrossCols()
    Dim LastCol As Integer
    Worksheets("Sheet1").Activate
    LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
    Column = 3
    Do
    Cells(2, Column).Formula = "=B2+C3"
   
    Row = Row + 1
   
    Loop Until LasCol
   
    End Sub


Just to be clear, the formula would change as the loop goes from column to column. I'm just not sure how to format
Code:
"=B2+C3"
to achieve this. Also, I'm not sure if
Code:
Loop Until LasCol
is a valid end to the loop. I'm open to any other more efficient looping process or way to make any part of the code more efficient. Any help is much appreciated.

Regards,
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,203,460
Messages
6,055,557
Members
444,797
Latest member
18ecooley

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