VBA Formula Issue

VbaHell

Well-known Member
Joined
Jan 30, 2011
Messages
1,220
Hello All, I am using Excel 2007

I am trying to find where my last column is and then add a formula starting at "C5" and then adding this formula to all the columns
Is this possible please

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

With Range("C5" & LC)
.FormulaR1C1 = _
"=SUMIFS('MIS - Customer Invoice'!C11,'MIS - Customer Invoice'!C42,R[-2]C,'MIS - Customer Invoice'!C21,R6C2)"
.Value = .Value

End With
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
try
Code:
With Range(Cells(5, 3), Cells(5, lc))
.FormulaR1C1 = _
"=SUMIFS('MIS - Customer Invoice'!C11,'MIS - Customer Invoice'!C42,R[-2]C,'MIS - Customer Invoice'!C21,R6C2)"
.Value = .Value
 
Upvote 0
Hi Micheal

Thanks for the quick reply.
I am getting a compile error on LC = .Cells(1, .Columns.Count).End(xlToLeft).Column

Invalid or unqualified reference.

Is this piece of code correct for looking for the last column

LC = Range("A" & Columns.Count).End(xlToLeft).Column
 
Upvote 0
Remove the periods
Code:
LC =Cells(1, Columns.Count).End(xlToLeft).Column
 
Upvote 0

Forum statistics

Threads
1,203,111
Messages
6,053,569
Members
444,673
Latest member
Jagadeshrao

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