Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 12th, 2013, 12:59 PM
Registered User
 
Join Date: Dec 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamic Selection

Hello. Noob here for macro vba.
I recorded a macro. Depending on the filter selection, the number of rows will change. I am attempting to get macros to base its selection on the number of rows regardless of having a defined range (as defined in the code below).

Currently this is the defined range it using but I would like to to base the selection on the cells with values from the top to the end. I tired selecting the entire column, but with the VLOOKUP formula, its taking a long time to process.

I like to change it on all three lines below. I am not sure if the "autofill" needs to change but if it does, please note that as well.

ActiveCell.FormulaR1C1 = "=VLOOKUP(RC2,SETS.WY!R2C2:R4487C4,3,FALSE)"
Selection.AutoFill Destination:=Range("AP2:AP141967")
Range("AP2:AP141967").Select


Can someone assist?

Thank You
 
Old December 12th, 2013, 01:14 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Are you trying to paste the formula for the entire range.

If you can briefly explain the requirements in would e useful

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old December 12th, 2013, 01:26 PM
Registered User
 
Join Date: Dec 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There are three columns (for columns B2,C2,D2) in the vlookup formula. The number of rows will vary depending on the filter of the active cell.

Looking at what the MACRO code, i believe it is here. I am not sure how to edit this so it selects on the range of data for those three columns for B2,C2,D2 and than an unknown number of rows.

Perhaps, I should try xlend function? but not sure how to insert this function with what MACRO has created the code for as follows:

ActiveCell.FormulaR1C1 = "=VLOOKUP(RC2,SETS.WY!R2C2:R4487C4,3,FALSE)"





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic selection of next page based on list box s gurupot JSP Basics 1 December 24th, 2007 06:03 AM
Dynamic Table Selection djobes31770 VB Databases Basics 7 November 19th, 2007 12:41 PM
Dynamic combo option selection deb1980 ASP.NET 2.0 Basics 3 April 23rd, 2007 01:26 PM
Dynamic ListBox Population n Selection nkrust ASP.NET 2.0 Basics 1 January 9th, 2007 05:05 AM
Dynamic Report By selection ... mostafa_h BOOK: Professional Crystal Reports for VS.NET 0 August 11th, 2006 07:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.