Hernan_g_f
New Member
- Joined
- Jul 26, 2022
- Messages
- 22
- Office Version
- 365
- Platform
- Windows
Hello all,
I'm writing the following code:
Dim rng3, rng4 As Range
Set rng3 = sh.Range("E16:H2500")
Set rng4 = sh.Range("E14:H14")
Dim x1 As Long
x1 = 100 / sh.Cells(14, 9).Value
For i = 1 To awx1
For j = 1 To 4
If rng1.Cells(i, 1).Value > 0 Then
rng3.Cells(i, j).Value = WorksheetFunction.VLookup(rng1.Cells(i, 1).Value, rng2, rng4.Cells(1, j).Value, 0) * x1
Else
rng3.Cells(i, j).Value = ""
End If
Next j
Next i
But x1 is incorrect. How can I write the correctly code so the line: rng3.Cells(i, j).Value = WorksheetFunction.VLookup(rng1.Cells(i, 1).Value, rng2, rng4.Cells(1, j).Value, 0) * x1
Thank your very much!
Hernán
I'm writing the following code:
Dim rng3, rng4 As Range
Set rng3 = sh.Range("E16:H2500")
Set rng4 = sh.Range("E14:H14")
Dim x1 As Long
x1 = 100 / sh.Cells(14, 9).Value
For i = 1 To awx1
For j = 1 To 4
If rng1.Cells(i, 1).Value > 0 Then
rng3.Cells(i, j).Value = WorksheetFunction.VLookup(rng1.Cells(i, 1).Value, rng2, rng4.Cells(1, j).Value, 0) * x1
Else
rng3.Cells(i, j).Value = ""
End If
Next j
Next i
But x1 is incorrect. How can I write the correctly code so the line: rng3.Cells(i, j).Value = WorksheetFunction.VLookup(rng1.Cells(i, 1).Value, rng2, rng4.Cells(1, j).Value, 0) * x1
Thank your very much!
Hernán