Forum

Merge 2 formulas fo...
 
Notifications
Clear all

Merge 2 formulas for specified column in vba code

6 Posts
3 Users
0 Reactions
67 Views
 m m
(@coral)
Posts: 10
Active Member
Topic starter
 

Hi every one could some one help me

i want to put and merge formula in column M:
=IF(M2=L2,"",M2) in this below code
i think i should put after or merge it with This row: range ("m2:m" & lr)="=L2-E2

it is obvious but if you need i will attach the excel sheet

Thank you so much

 

Sub SUBTRACT & AVERAGE ()

lr = Cells(Rows.Count, "a").End(xlUp).Row

Set yl = Range("b1:b" & lr)

yl.Copy Range("q1")

Range("m2:m" & lr) = "=L2-E2"

Range("q1:q" & lr).RemoveDuplicates Columns:=1, Header:=xlYes

clr = Cells(Rows.Count, "q").End(xlUp).Row

Range("r1") = "Average"

Range("r2:r" & clr) = "=AVERAGEIFS($M$2:$M$" & lr & ",$B$2:$B$" & lr & ",Q2)"

End Sub

 
Posted : 08/05/2020 9:01 am
(@purfleet)
Posts: 412
Reputable Member
 

Can you add the workbook so we dont need to recreate it?

Purfleet

 
Posted : 08/05/2020 1:59 pm
 m m
(@coral)
Posts: 10
Active Member
Topic starter
 

Hi  Mr Purfleet

 
Posted : 09/05/2020 5:14 am
 m m
(@coral)
Posts: 10
Active Member
Topic starter
 

Hi

what i mean is

=if(L2-E2=L2;true [BLANK];false[L2-E2])

or

=if(l2-e2=l2;"";if(l2-e2<>l2;"l2-e2'))

or

Range("m2:m" & LR) = "=IF(L2-E2=L2,"",L2-E2)"

could you please check syntax

thank you so much

 
Posted : 11/05/2020 8:10 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi mm,

Thanks for the workbook but it's an XLSX so we'd still need to copy/paste your code from the forum into it to test it out 🙂  Please supply the XLSM file if you need us to look at your code.

I'm not sure why you are turning to VBA for this? maybe I don't have the full picture if what you are doing.

I've turned your data into a table to that when you enter the formula in Col M it is copied down to all rows.

You can use UNIQUE to get a unique list of values from the sal1 column, and then the AVERAGEIFS formula in Col Ris as you have it in your VBA.

Regards

Phil

 
Posted : 11/05/2020 10:19 pm
 m m
(@coral)
Posts: 10
Active Member
Topic starter
 

hi 

thank you Mr  Treacy

i appreciate your help

some one else  helped me in this issue and finally i found it

i wanted this below formula 

 
Range("m2:m" & LR) = "=IF(L2-E2=L2 ,"""",IF(L2-E2=-E2,"""",L2-E2))"

it has been solved

 
Posted : 12/05/2020 5:23 am
Share: