Search: | |||||

| ||||

Home » Forum » MS Office | RSS Feeds |

Hi all,

I would like to ask how can I make the range in a formula in the VBA code becomes a variable, but not hard code it?

My original code:

Range(Cells(2, 44), Cells(bill_lastrow, 44)).Formula = "=VLOOKUP(AQ2,sheet2!$N$1:$O$1144,2,FALSE)"

I would like to make "sheet2!$N$1:$O$1144" as variable, so when the last row of sheet2 not equal to 1144, let say, last row = 2224, it can still work without hard coding it.

Thanks a lot!!

Didn't find what you were looking for?
Find more on VBA variable range in a formula
Or get search suggestion and latest updates.

Related Topics:

- VBA Code for pasting a set of formulas down a data range
- Formula using range name in VBA code
- Using a Defined Variable Range in a VBA SumIf
- cells containing formula that refer to user-defined VBA function
- VBA or array formula?
- VBA code to add values in two cells which have formulas
- Getting a formula to copy from inside VBA
- VBA Formula prob
- formula help but not vba please
- Copy down formula with vba
- VBA and Arrays/Ranges
- Reference range row and column in VBA
- Insert Rows, based on data in range, using VBA
- How to obtain minimum in a range with VBA
- Using VBA to name Ranges
- Reference range row and column in VBA
- VBA Excel Coding for dynamically changing function range
- Variable Ranges, Loop?
- Error when using variable to name a range
- Summing a range of variable size
- How to declare a range using a variable
- how to get data into vba variable
- VBA Binary variable/constant type ?
- making a spreadsheet cell name a global variable in the VBA project
- highlight a range using a named range