Solved

VBA to Clear a Region and Then Perform Vlookups

Posted on 2011-09-15
3
220 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
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
StephenJR earned 500 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel formula need currency format 1 23
Excel change font color in formula 19 28
Loop with matrices. Please help me! 16 41
Excel Sheet Data Finding 14 16
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

856 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