how to return value not formula

Kade

Active Member
Joined
Jul 20, 2002
Messages
258
Hi all

I would like this code to return the value into the d7, not the formula

Range("d7") = "=(VLookup(0, myrange, 3, False))"


currently I am add the following but it is cumbersome

Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False

tia
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi expel

no when I try it
Range("d7").Formula = "=(VLookup(0, myrange, 3, False))"
I still get the formula in the cell d7 not the value from the table

I originally thought range("d7").value but this also only returns formula.

Is it possible I have made some setting wrong?

tia
 
Upvote 0
Sorry, I couldn't test your formula, as i didn't have that data. I tested it substituting NOW(), and it worked fine.

It is possible to alter the sheet to display formulae in the cells instead of the values.

Try Press CTRL + ` (grave accent), to toggle this setting, or go to Tools | Options | View tab, and see if formulas is checked in the Window Options at the bottom.

Hope this helps
 
Upvote 0
Kade,

See if this code helps your understanding:<pre>
Sub UseVLookup()

Set rngVL = Workbooks("Book1.xls").Worksheets("Sheet1").Range("A:B")

For i = 2 To 10
LUvalue = Cells(i, 1).Value
Cells(i, 2).Value = Application.WorksheetFunction.VLookup(LUvalue, rngVL, 2, False)
Next i


End Sub</pre>

Make changes as appropriate to accommodate your situation.

enjoy
This message was edited by Bariloche on 2002-12-12 08:48
 
Upvote 0
Yes, follow Bariloche's advice, modify your code to :
Range("D7").Value = Application.WorksheetFunction.VLookup(0, myrange, 3, False)

Merry Christmas
 
Upvote 0
Yes, follow Bariloche's advice, modify your code to :
Range("D7").Value = Application.WorksheetFunction.VLookup(0, myrange, 3, False)

Merry Christmas
 
Upvote 0

Forum statistics

Threads
1,214,639
Messages
6,120,679
Members
448,977
Latest member
dbonilla0331

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top