cmefly
Well-known Member
- Joined
- May 13, 2003
- Messages
- 683
hi,
i've got a code that works. The vlookup is working but retrieving a rounded version of the number its suppose to retrieve. why is it rounding it for me??
Code:
Sub Macro1()
Dim a, charge As String
Dim b As Integer
Dim k As Range
Dim i, j As Integer
Dim l As Long
Windows("whatsnew.xls").Activate
Sheets("Sheet1").Select
a = Range("B1").Value
Windows("whatsnew.xls").Activate
For Each k In Range("a1:a100")
If k.Value = a Then
b = k.Row
End If
If b > 0 Then
Exit For
End If
Next k
'Range("B10").Value = b
Windows("whatsnew.xls").Activate
Range("a1").Select
For i = 2 To 68
Cells(2, i).Select
charge = Cells(2, i).Value
Cells(b, i).Select
j = Application.VLookup(charge, Workbooks("filename.xls").Sheets("Sheet1").Range("A3:e70"), 4, False)
Cells(b, i).Value = j
Next i
End Sub
i've got a code that works. The vlookup is working but retrieving a rounded version of the number its suppose to retrieve. why is it rounding it for me??
Code:
Sub Macro1()
Dim a, charge As String
Dim b As Integer
Dim k As Range
Dim i, j As Integer
Dim l As Long
Windows("whatsnew.xls").Activate
Sheets("Sheet1").Select
a = Range("B1").Value
Windows("whatsnew.xls").Activate
For Each k In Range("a1:a100")
If k.Value = a Then
b = k.Row
End If
If b > 0 Then
Exit For
End If
Next k
'Range("B10").Value = b
Windows("whatsnew.xls").Activate
Range("a1").Select
For i = 2 To 68
Cells(2, i).Select
charge = Cells(2, i).Value
Cells(b, i).Select
j = Application.VLookup(charge, Workbooks("filename.xls").Sheets("Sheet1").Range("A3:e70"), 4, False)
Cells(b, i).Value = j
Next i
End Sub