excel - VBA VLOOKUP Convert to Values Gives #N/A -


i'm having trouble vlookup in vba. here's example of code i'm using:

sub macro15() ' ' macro15 macro dim lr long lr = cells(rows.count, "a").end(xlup).row range("b1:b" & lr).formular1c1 = _ "=vlookup(rc[-1],'https://internal_sharepoint_address     /[vendor_information.xlsx]sheet1'!r3c3:r150c18,4,false)" range("c1:c" & lr).formular1c1 = _     "=vlookup(rc[-2],'https://internal_sharepoint_address /[vendor_information.xlsx]sheet1'!r3c3:r150c18,5,false)" range("b1:c" & lr) .value = .value end end sub 

the problem values in columns b & c (the vlookup formulas) return value of #n/a.

however, if stop code before converting formula values (the "with range("b1:c" & lr)" line), vlookup formula returns correct values.

also strange - if clear contents of columns b & c , re-run above code, values return fine. if try add second cycle vba, however, not work.

any wisdom can provide huge help. i've been stuck on long time, , i'm @ wit's end.

thanks all, david

you'll need add in step runs calculation cycle before try replace value:

application.calculate 

edit comment: imagine retrieving lookup data linked workbook on sharepoint site take awhile. maybe add delay loops? can make 2 separate macros (one ending formulas, , second 1 starting @ paste values), , run them separately pause in between?


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -