?
Solved

VBA to Clear a Region and Then Perform Vlookups

Posted on 2011-09-15
3
Medium Priority
?
224 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

752 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