Solved

VBA to Clear a Region and Then Perform Vlookups

Posted on 2011-09-15
3
217 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now