ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   vlookup macro pasting (https://www.excelbanter.com/excel-programming/357878-vlookup-macro-pasting.html)

cbh35711[_8_]

vlookup macro pasting
 

So i've got this forumla "=E3*VLOOKUP(D3,units,2,FALSE)"
I'm using a macro to fill a column in a sheet with that forumla, but I
need E3 and D3 to change as they would if i autofilled down. So they're
looking at the column in the same row as it is.
Any ideas?


Thanks,

Chris


--
cbh35711
------------------------------------------------------------------------
cbh35711's Profile: http://www.excelforum.com/member.php...o&userid=30276
View this thread: http://www.excelforum.com/showthread...hreadid=529267


Tom Ogilvy

vlookup macro pasting
 
this does what you want. Adjust to match your particulars.

Range("F3:F200").formula = "=E3*VLOOKUP(D3,units,2,FALSE)"

--
Regards,
Tom Ogilvy



"cbh35711" wrote:


So i've got this forumla "=E3*VLOOKUP(D3,units,2,FALSE)"
I'm using a macro to fill a column in a sheet with that forumla, but I
need E3 and D3 to change as they would if i autofilled down. So they're
looking at the column in the same row as it is.
Any ideas?


Thanks,

Chris


--
cbh35711
------------------------------------------------------------------------
cbh35711's Profile: http://www.excelforum.com/member.php...o&userid=30276
View this thread: http://www.excelforum.com/showthread...hreadid=529267



jordun

vlookup macro pasting
 

Hi
When using Vba, take advantage of cells(row,column) to do taks like
this.

I would suggest this code

Dim Ix as long, units as range

set range=sheets("???").range("????")

for Ix = [the first row in the range] to [last row in the range]
cells(Ix,??)=
cells(Ix,5)*worksheetfunction.vlookup(cells(Ix,4), units,2,0)
next Ix


--
jordun
------------------------------------------------------------------------
jordun's Profile: http://www.excelforum.com/member.php...o&userid=33118
View this thread: http://www.excelforum.com/showthread...hreadid=529267


cbh35711[_9_]

vlookup macro pasting
 

Great Tom

Thanks,

Chris


--
cbh35711
------------------------------------------------------------------------
cbh35711's Profile: http://www.excelforum.com/member.php...o&userid=30276
View this thread: http://www.excelforum.com/showthread...hreadid=529267



All times are GMT +1. The time now is 10:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com