Crashed and burned

swaink

Active Member
Joined
Feb 15, 2002
Messages
432
Hi All

I have been trying without success to apply a formula using VBA to a range on a single row.

I want to use VBA to add the following formula starting at column N, I intend to use lastrow = range("A65535").end(xlup).row and use that result as part of the formula build to cater for increasing rows, I also intend to find the last column in the range.

=SUM(IF(ISNUMBER(N6:N207),N6:N207,0)/100*$I$6:$I$207)

When the formula is reflected across the row the last part of the formula would anchor to column I.

However I just can't seem to get this to work and wonder if someone could assist me in solving this problem please?

All advice appreciated

Regards

Kevin
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi Peter

Thanks for the reply

I'm looking to offset the row from the lastrow, in this example it would be in row 210

Kev
 
Upvote 0
Try like this

Code:
Sub Test2()
Dim LR As Long, LC As Long
LR = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
LC = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column
Range(Cells(LR + 1, 14), Cells(LR + 1, LC)).Formula = "=SUM(IF(ISNUMBER(N6:N" & LR & "),N6:N" & LR & ",0)/100*$I$6:$I$" & LR & ")"
End Sub
 
Upvote 0
Hi Peter

Not only have you solved the problem yet again for me and I thank you..

But you have also taught me a new approach to finding the last row and last column too

Your help is appreciated

Kevin
 
Upvote 0

Forum statistics

Threads
1,224,524
Messages
6,179,308
Members
452,904
Latest member
CodeMasterX

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