ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   selecting a cell based on lookup with VBA (https://www.excelbanter.com/excel-programming/343006-selecting-cell-based-lookup-vba.html)

PhilipsBernard

selecting a cell based on lookup with VBA
 
Hi!

I have the following problem: Sheet 1 is a matrix of which the two axes
describe two variables. Sheet 2 contains values of variable 1 in column A and
values of Variable 2 in column B. Based on the pair of these values in column
A and B, I want to look up for each row the corresponding value from the
matrix (based on the values of variable 1 and 2). How can this be solved
using VBA?

Thanx for your suggestions!

PhilipsBernard

selecting a cell based on lookup with VBA
 

Problem is solved using the following code:

Sub LookupDirectLabour()
Dim ActiveCell As Range
Dim Cell As Range


For DirectLabourRow = 2 To Cells(Rows.Count, 1).End(xlUp).Offset(1,
0).Row

Set DirectLabourCellWC = Worksheets("Direct Labour").Cells
_(DirectLabourRow, 1)
Set DirectLabourCellAcc = Worksheets("Direct Labour").Cells
_(DirectLabourRow, 2)


With DirectLabourCellWC

For colIndex = 5 To 27
With Worksheets("COOMonthWC").Cells(7, colIndex)
If .Value = DirectLabourCellWC.Value Then
With DirectLabourCellAcc
For rwIndex = 10 To 91
With
Worksheets("COOMonthWC").Cells(rwIndex, 1)
If .Value =
DirectLabourCellAcc.Value Then
DirectLabourCellWC.Offset(0,
3).Value = _ Worksheets("COOMonthWC").Cells(rwIndex, colIndex) *
(DirectLabourCellWC.Offset(0, 2) / 100)
End If
End With
Next rwIndex
End With
End If
End With
Next colIndex

End With
Next

End Sub

"PhilipsBernard" wrote:

Hi!

I have the following problem: Sheet 1 is a matrix of which the two axes
describe two variables. Sheet 2 contains values of variable 1 in column A and
values of Variable 2 in column B. Based on the pair of these values in column
A and B, I want to look up for each row the corresponding value from the
matrix (based on the values of variable 1 and 2). How can this be solved
using VBA?

Thanx for your suggestions!



All times are GMT +1. The time now is 03:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com