Sub MyLookup()
Dim lRow As Long
lRow = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
With Sheets("Sheet1")
.Range("B2:B" & lRow) = Application.WorksheetFunction.VLookup(.Range("A2:A" & lRow), Sheets("Sheet2").Range("A:B"), 2, 0)
End With
End Sub
Example.xls
Sun ApplyNames()
Dim rngID As Range, rngLookup As Range
'assume Sheet1 holds the 500 IDs and blank name column
'assume Sheet2 range A2:B11 holds your unique IDs and the Names you want to apply to Sheet1
With Sheets("Sheet1")
Set rngID = .Range("A2:A" & .Cells(.Rows.Count,"A").End(xlUp).Row) 'assume header in row 1
End With
Set rngLookup = Sheets("Sheet2").Range("A2:B11") 'amend as appropriate
'now apply names using Vlookup function of the WorksheetFunction object:
rngID.Offset(0,1).Value = Application.Vlookup(rngID,rngLookup,2,False)
End Sub
Sub test1()
Dim n As Long
For n = 1 To Range("A1:AB5000").Count
Range("A1:AB5000").Cells(n).Value = 1
Next n
End Sub
Sub test2()
Range("A1:AB5000").Value = 1
End Sub
Sub test1()
Dim n As Long
With Sheets("Sheet1")
For n = 1 To 5000
.Cells(n, 1) = 1
Next n
End With
End Sub
Sub test1()
Dim n As Long
For n = 1 To Range("A1:AB1000").Count
Range("A1:AB1000").Cells(n) = "=5+2"
Next n
End Sub
Sub test2()
Range("A1:AB50000") = "=5+1"
End Sub
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
Excel formula Sumif not working | 4 | 28 | |
Excel conditional formatting based on 'zero value' | 6 | 20 | |
How to transform one row line like this in excel table 2010? | 8 | 20 | |
vba delete dups is not working | 35 | 15 |
Join the community of 500,000 technology professionals and ask your questions.