# Posts by Natit1

The second option worked great

this one - (Range("r1").FormulaR1C1 = "=sum(R1C1:R" & Lrow & "C" & Lcol & ")")

Sorry, but it doesn't work

The sheet is attached here.

## Files

HI,

Can someone help and will tell me what's wrong with this command:

Code
``Range("r1") = "=sum(" & Range(Cells(1, 1), Cells(Lrow, Lcol)) & ")"``

Thanks

Nati

I found the answer relative to the number of columns .

In the example the columns are "d" (this column is always the first, so it is fixed for me) to "o", which means from 4 to 15.

But sometimes I'll have the data till column "s" or to "z", and I want the formula to be flexible of course (I know the number of the the last column)

Hope it is clear know Thx

Hi,

I would like to fit this code:

Range("start!b14").Formula = "=sumif(data" & "!\$D\$2:\$O\$" & Lrow & ",""<0"")"

to work with relative columns (instead of the fix one here)

Tia

Nati

I know the process with the OptionBox.

I need the formula that gives the result according the data from the OptionBox (which gives me the column number) and the years selected (which are the True and the False)

The column number (5 in this case) selected by OptioBox which the user select in another sheet.

Example:

1. If year 2018="True" and 2019&2020 = "False", and column 5 is selected (meaning Data5 - I know that the absolute column is 8 ), the result for Unit1 will be - 58

2. If year 2018="True" and 2019 = "True" and 2020 = "False", and column 2 is selected, the result for Unit1 will be - 192

and so on..

Great

Thanks

And I have A little more complexed need.

How do I sum according to sumif that you answered me, but this time with selecting specific column.

to-ozgrid-forum.xlsx

Hi,

I'm looking for the formula that will sum each data column (in the result line)to-ozgrid-forum.xlsxto-ozgrid-forum.xlsx according to the status column (means that if the line status is true, the sum will be added, if false then not added)

Tia

Nati

Ooops

Here is the sheet ## Files

Hi 2 u all,

Need help in how to write the next code line in VBA (what is suppose to be in the question marks of course):

lrow = 24

for i = 1 to 3

cells(lrow +1, i) = "sum(????????????????)"

next i

TIA

Nati