Just one more quick question and then I will go away for a while
I have 3 conditions, call them boxes a,b and c.
Box A is a number between 6 and 8
Box B is a number between 0 and 10
Box C is either Y or N
Depending on the results of these 3 cells a vaue is taken from a table.
Short of saying If Cells(3, 32) = 6 or 7 or 8" etc, is there are number between function?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Cells(3, 32) = ""Number between 6 & 8""And Cells(7, 32) = number between 0 and 10 And Cells(9, 32) = "N" Then
Cells(50, 21) = Cells(3, 5)
End If
Last edited by ndtsteve; May 1st, 2012 at 05:05 AM.
Reason: Resoved
Sub between()
Dim firstCondition As Boolean
Dim secondcondition As Boolean
If Cells(3, 3) > 6 And Cells(3, 3) < 8 Then
firstCondition = True
End If
If Cells(4, 3) > 0 And Cells(4, 3) < 10 Then
secondcondition = True
End If
If firstCondition And secondcondition Then
MsgBox "Both are true"
End If
End Sub
I looked at the file, and I'm not real clear on what you are doing (or trying to do). I'm not sure how the "matrices" fit with your conditions and logic.
Maybe try explaining one more time, in laymen's terms?
There are three variables that can be entered, line size, length and Y or N to INS. These variables would eventually come from another page in the workbook which I would create, something like a summary page. Currently, all this info (and a lot of other stuff) is on different files and I am trying to put it all in 1 file and "automate" it so that with minimal data entry it will populate as much as I can work out how to do without having to keep jumping between files. This same basic method which is created for this would be adapted to use with other data sheets with similar data.
What I hope to achieve is to have the final entry (at bottom of page) to appear automatically depending on what combination of the 3 variables I use, rather than manually looking thru the table and picking out the relevant number.
i.e. Size = 6
Length = 47
INS = Y would show value 2821
or
Size = 20
Length = 23
INS = N would show value 4015
This picks the number that matches these variables from the table on the page.
Hope this is a bit clearer on what I am trying to get to..........thanks
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Cells(3, 32) >= 6 <= 8 Then
If Cells(6, 32) >= 0 <= 10 Then
If Cells(9, 32) = N Then
Cells(50, 21) = Cells(3, 5)
End If
End
Sub condits()
Dim eqSize As Integer
Dim length As Integer
Dim YorN As String
Dim sizeRows As Integer
Dim lenCol As Integer
Dim finalVal As Integer
eqSize = Cells(3, 32)
length = Cells(6, 32)
yorno = Cells(9, 32)
Select Case eqSize
Case 6, 7, 8
sizeRows = 3 '3 or 4 in reality
Case 10
sizeRows = 8
Case 12, 13, 14
sizeRows = 13
Case Else
'finish the coding
End Select
Select Case length
Case 0 To 10
lenCol = 5
Case 11 To 30
lenCol = 9
Case 31 To 50
lenCol = 13
Case Else
'finish
End Select
If Cells(9, 32) = "Y" Then
YorN = "y"
Else
YorN = "N"
End If
If YorN = "y" Then
finalVal = Cells(sizeRows + 1, lenCol)
Else
finalVal = Cells(sizeRows, lenCol)
End If
MsgBox finalVal
End Sub