Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Using a Defined Variable Range in a VBA SumIf

  Asked By: Scott    Date: Oct 13    Category: MS Office    Views: 1004
  

Hi,

I am trying to use a Defined variable range inside a VBA Script SumIf.

A sample of the code is:

Range("C7").Select
ActiveCell.FormulaR1C1 = "=SUMIF(Sheet2!R[-6]C[-2]:R[515]C[7],1101,Sheet2!C)"

I would like to Replace Sheet2!R[-6]C[-2]:R[515]C[7] with a Range Variable called myRange.

I have defined the variable as follows:

Dim MyRange As Range
Set MyRange = Worksheets("Sheet2").Range("A1:J512")

However when I try to the replacement I get a NAME error when running the VBA Macro.

Any suggestions?

Thanks,
Scott

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Using a Defined Variable Range in a VBA SumIf Or get search suggestion and latest updates.




Tagged: