LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error in setting formula (Match) with dynamic variables

Hi all,

I have extracted the problem codes from my VB program in Excel. Actually, I
would like to set the formula in cell M1 in run time to

=MATCH("Soya Products",N14:N153,0) <----- Expected result

However, when I use the following code, the formula is set to
=MATCH("Soya Products",'N14':'N153',0) <----- Result generated by following
code

Can any one give me some advice? Thanks.

My Code is as follows:
---------------------------------------------------------------------------------------------
Dim myRange As String
Dim eRange As Range
Dim Lrow As Long

Lrow = Cells(Rows.Count, "N").End(xlUp).Row
myRange = "N14:N" & Lrow

Range(myRange).Select
Selection.Name = "eRange"
Set eRange = Range("eRange")
Range("M1").Select

ActiveCell.FormulaR1C1 = "=MATCH(""" & selectedCat(i) & """," &
eRange.Address(False, False) & ",0)"
ActiveWorkbook.Names("eRange").Delete

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Application Defined Error setting a formula via VBA BerkshireGuy[_2_] Excel Programming 2 October 27th 06 02:16 AM
IF INDEX MATCH formula inside VBA with variables [email protected] Excel Programming 0 October 10th 06 12:54 PM
Setting Public Variables Error clmarquez[_10_] Excel Programming 8 January 16th 06 05:25 PM
Setting dynamic range in a formula Phillycheese5 Excel Worksheet Functions 9 June 10th 05 07:58 PM
Setting variables to Nothing Matt Jensen Excel Programming 5 January 12th 05 02:25 AM


All times are GMT +1. The time now is 06:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"