Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VBA to Clear a Region and Then Perform Vlookups

Posted on 2011-09-15
3
Medium Priority
?
226 Views
Last Modified: 2012-05-12
Hi,
Can you help me to add VBA code to my macro to clear a region and then add a vlookup (equation) to cells.

Attached is a sample code. It's kind of spread-out but I deleted everything but the applicable portions.  Need to Clear AU7 to AZ1000 and then have code to do what the vlookup functions do now, for each row for columns AV and AW:

=IF(ISBLANK(AA7),"",(VLOOKUP(AA7,$AE$7:$AF$107,2,FALSE)))
=IF(ISBLANK(AB7),"",(VLOOKUP(AB7,$AI$7:$AJ$13,2,FALSE)))

Thanks,
Dennis
EOS-Assistant-Experts-Exchange-t.xls
0
Comment
Question by:u002dag
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
StephenJR earned 2000 total points
ID: 36544234
This perhaps, though I suppose you may not need to go down to 1000 every time?
Range("AU7:AZ1000").ClearContents
Range("AV7:AV1000").Formula = "=IF(ISBLANK(AA7),"""",(VLOOKUP(AA7,$AE$7:$AF$107,2,FALSE)))"
Range("AW7:AW1000").Formula = "=IF(ISBLANK(AB7),"""",(VLOOKUP(AB7,$AI$7:$AJ$13,2,FALSE)))"

Open in new window

0
 

Author Comment

by:u002dag
ID: 36544594
Thanks,
Do you know why I get a compile error: Syntax error when I use a similar approach for the following and how would you overcome it?:

Range("f7:f100").Formula = "=hyperlink(concatenate($al$5,am7,".pdf"),AC7"
0
 
LVL 24

Expert Comment

by:StephenJR
ID: 36546468
Two things. First, you're missing a closing bracket at the end, and, second, you need to double-up quotes in VBA:

Range("f7:f100").Formula = "=hyperlink(concatenate($al$5,am7,"".pdf""),AC7)"

Open in new window

0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question