Incremente row (VBA) and then Using SommeProduct (probleme with Sommeproduct Excel) - vba

Thanks to help me)))
At first I incremente the row + 1 with the value that I have insert with VBA. That's working...
ThisWorkbook.Worksheets("Données Enregistrées").Range("A10:AL10").Copy _
Destination:=ThisWorkbook.Worksheets("Données Enregistrées").Cells(Rows.Count, 1).End(xlUp).Offset(1)
And then I want to use the value that I have insert to modify them..I use excel for that.. and I got 0...But If I insert value by hand that's working...
=SOMMEPROD((A16:A22=A2)*(B16:B22))
Any Solution??
Hope that you have understood, thanks)))

You can use Sommeprod (sumproduct for english) on entire columns like this :
=SOMMEPROD((A:A=D2)*(B:B)*1)
But if you test a value that is in the same column it can be a problem I think, so show us a bit more so we can answer more accurately!
And yes, SommeProd is an array formula so you have to do Ctrl+Shift+Enter when you are done typing it!
A bientôt

Related

Autofill but skipping a column

My current formula is:
=IF(COUNTIF('W/C 1/8/22'!B$47:C$53,""&$B12&""),"S1","-")
When dragging/autofilling I would like the next box to refer to columns 'D'&'E'(and then the following 'F'&'G') and so on, basically to skip along as I have merged two columns on the 'w/c' sheet.
D11 is the first box this formula will be in and hopefully will be able to drag
/autofill from there.
I have tried lots of different methods but can't seem to insert the correct formula to make it work. Any help would be most appreciated, thank you!

Vlookup with three comments depends on found value vba code or formula ( very hard to find solution)

I have very difficult scenario where i need to mention three comments by tow V lookup. let me explain you situation.
We are getting three sheets in workbook with values every weekly.
sheet1 range A1 to A5 value , lookup values sheet2 range A:B and lookup value sheet3 range A:B. yes i can able to put two V lookup , but problem is 3 comments i need to show in single output.
When i lookup values found in sheet2 need comment as "found value in sheet2" , if not it has to lookup sheet3 range if found then it has to give comment as "found value in sheet3" and if value not found need to give comment as " invalid data".
through vba can is it possible and three comments should be sheet1 in a single output based on values?
am looked in google i can use IFSA formula and apply formula but i cant provide three comments ...
For us its really hard every weekend , Please help me with VBA Code or Any formula at one shot for three comments ?
Really appreciate your help
You can actually have up to 7 Nested (IF) functions in Excel - Nested Formula Limit
You need to make sure that you properly close each function. This can be seen when editing the formula, it will highlight the opening/closing parentheses as you arrow through the formula.
If it tries to select a range while using the arrow keys, hit F2 to toggle between Edit/Enter modes.
I think you want this...
=IF(ISNA(VLOOKUP(A1,Sheet1!A1:B4,2,FALSE)),IF(ISNA(VLOOKUP(A1,Sheet2!A1:B4,2,FALSE)),IF(ISNA(VLOOKUP(A1,Sheet3!A1:B4,2,FALSE)),"Invalid Data", "Sheet 3"),"Sheet2"),"Sheet1")
Actually, on second thought, I assume you want whatever is in Column B
=IFNA(VLOOKUP(A1,Sheet1!A1:B4,2,FALSE),IFNA(VLOOKUP(A1,Sheet2!A1:B4,2,FALSE),IFNA(VLOOKUP(A1,Sheet3!A1:B4,2,FALSE),"Invalid Data")))
If I understand correctly, you need to determine if the first VLOOKUP is found, and if not, use the second VLOOKUP. Thats super simple. Assuming the formula Profex provided doesn't work:
=IF(IFERROR(VLOOKUP("A1", Sheet2!A1:B4, 2, False), "Err")="Err",IFERROR(VLOOKUP("A1", Sheet3!A1:B4, 2, False), "Not Found"), VLOOKUP("A1", Sheet2!A1:B4, 2, False))

Inserting vlookup function via vba adds brackets on column

I've got a problem with brackets in complex vlookup "insert function".
It's needed for a plan for each day of week. Because of slow performance of workbook I decided to turn on/off each day of plan, entire plan works but the column with expeditions. Code for part of "U" column is:
Range(Cells(firstm, "U"), Cells(lastm, "U")) = "=IF(RC2=0,IF(RC[-8]>0,
IF(ISERROR(VLOOKUP(G:G,Expedition!F:H,3,0)),R1C22,VLOOKUP(G:G,Expedition!F:H,3,0)),R1C22)
,IF(ISERROR(VLOOKUP(G:G,Expedition!F:H,3,0)),R1C22,VLOOKUP(G:G,Expedition!F:H,3,0)))"
It's quite messy, but it works :) at least in sheet.
The problem is that part of inserted formula in cell is
VLOOKUP(G:(G);Expedition!F:(H);3;0)
instead of
VLOOKUP(G:G;Expedition!F:H;3;0)
if only VLOOKUP is used, it works fine, I have no idea why in this example are those brackets.
Any ideas?
//edited for better understanding
Try to use either R1C1 or A1 reference style and specify the formula type, for example:
Range(Cells(firstm, "U"), Cells(lastm, "U")).FormulaR1C1 = "=IF(RC2=0,IF(RC[-8]>0, IF(ISERROR(VLOOKUP(C[7],Expedition!C[6]:C[8],3,0)),R1C22,VLOOKUP(C[7],Expedition!C[6]:C[8],3,0)),R1C22) ,IF(ISERROR(VLOOKUP(C[7],Expedition!C[6]:C[8],3,0)),R1C22,VLOOKUP(C[7],Expedition!C[6]:C[8],3,0)))"
edit: of course the relative references G:G etc have to be changed to relative references C[7]. C[7] becomes G:G while C7 becomes $G:$G.
Well, it perfectly works.. when I'm using that in half of the code, why haven't I used that for columns?.. :) Thank you!

Comparing Excel cell values and a userform Textbox

Ok, the problem is that im working in a excel userform, but i cannot find a way to do a comparation between a textbox value and a cell value and if some statement is meet it will write other value to another textbox (the program is has already been made with the use of excel macros, but i wanted to make it look better, and im trying to use the userform)
Here is the code i am trying to run
Select Case (TextBox1)
Case Is <= Sheet2.Cells(3, 8)
TextBox21 = 4
End Select
(When you run the code its does nothing)
Do i need to do something else to make it work?, because im using the same excel file of my tables to make the userform,if i'm confusing something please do let me know.
Thanks for your answer and sorry for my English.
If CInt(TextBox1.Value) <= CInt(Sheet1.Cells(1, 1).Value) Then
TextBox2.Value = 4
end if
The problem is that you are trying to compare strings, when you should be comparing numbers. You just need to convert the values to an int. You might also want to put in a little more validation to ensure that textBox1 and cells(1,1) are in fact numeric values.

How do you use the value of a named cell in a macro in a different sheet, same workbook?

I'm just not getting it, I'm using Excel 2003 and am totally confused as I'm just not getting it ...can anyone help? I need to check that named value with a number of column headings on the active sheet and then insert a column to the left of the column holding the matching text. I'm sure that bit is very hard - but I'm not even able to get started here...
Well, to get your named value column (which I presume is a named range...), you would use:
ActiveWorkbook.Sheets("mySheet").Range("myRange").Column
So you could do something like:
myNamedRange = ActiveWorkbook.Sheets("mySheet").Range("myNamedRange").Value
myCol = ActiveWorkbook.Sheets("myMainSheet").Rows("1:1").Find(myNamedRange).Column
ActiveWorkbook.Sheets("myMainSheet").Cells(1, myCol).EntireColumn.Insert