Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Filling down formula to cover complete range


Hi,

this is something I will quite often have to do.
Where I havea range of data, and want to put, say, a VLOOKUP in
column and have the macro automatically copy the VLOOKUP down to ever
row that has data - how can I acheive this?

my example.
I need a macro to insert two columns C and D
the data spans from A to AB.

once they have been inserted, i need to put the following in C2 an
then copy it down.

=VLOOKUP(B2,[sheamcat.xls]Sheet1!C1:C4, 3, 0)

and a similar thing into D2

=VLOOKUP(B2,[sheamcat.xls]Sheet1!C1:C4, 4, 0)

any ideas

--
matp
-----------------------------------------------------------------------
matpj's Profile: http://www.excelforum.com/member.php...fo&userid=2107
View this thread: http://www.excelforum.com/showthread.php?threadid=48178

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Filling down formula to cover complete range

Sub FillDownFormulae()
Dim iLastRow As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Range("C2").Formula = "=VLOOKUP(B2,[sheamcat.xls]Sheet1!C1:C4, 3, 0)"
Range("C2").AutoFill Range("C2").Resize(iLastRow - 1)
Range("D2").Formula = "=VLOOKUP(B2,[sheamcat.xls]Sheet1!C1:C4, 4, 0)"
Range("D2").AutoFill Range("D2").Resize(iLastRow - 1)

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"matpj" wrote in
message ...

Hi,

this is something I will quite often have to do.
Where I havea range of data, and want to put, say, a VLOOKUP in a
column and have the macro automatically copy the VLOOKUP down to every
row that has data - how can I acheive this?

my example.
I need a macro to insert two columns C and D
the data spans from A to AB.

once they have been inserted, i need to put the following in C2 and
then copy it down.

=VLOOKUP(B2,[sheamcat.xls]Sheet1!C1:C4, 3, 0)

and a similar thing into D2

=VLOOKUP(B2,[sheamcat.xls]Sheet1!C1:C4, 4, 0)

any ideas?


--
matpj
------------------------------------------------------------------------
matpj's Profile:

http://www.excelforum.com/member.php...o&userid=21076
View this thread: http://www.excelforum.com/showthread...hreadid=481783



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
A single SUMPRODUCT Excel formula cover four worksheets wilchong via OfficeKB.com New Users to Excel 4 May 18th 08 05:53 AM
If statement to cover range TheLeafs Excel Worksheet Functions 3 April 7th 06 04:27 PM
?set up a print range to cover multiple pages in excel JBC Excel Worksheet Functions 3 March 6th 06 03:04 PM
HELP! Single cell formula to calculate weeks cover of stock on forward sales. [email protected] Excel Worksheet Functions 2 January 13th 06 10:24 AM
how to cover the formula Lawrence Excel Worksheet Functions 7 December 16th 05 05:23 PM


All times are GMT +1. The time now is 04:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"