joey peanuts
New Member
- Joined
- Mar 20, 2011
- Messages
- 18
Excel 2007
I am getting an error on the bolded line. I have used Intersect successfully in other areas of my code. I think the problem is with my attempt to use the value of ExactRange1 as a Range object. In my trial, ExactRange1 becomes the name of a valid named range ("RBARECT_STYLE").
Sub RbaRectRetail()
Dim ExactRange1 As String, ExactRange2 As String, ExactRange3 As String, ExactRange4 As String, ExactRange5 As String
Dim SpatialRange1 As String, Tax As String, Comm As String, Marg As String, Disc As String
Dim lineNUMBER(60) As String
Dim Erange1VALUE(60) As String
Dim Erange2VALUE(60) As String
Dim Erange3VALUE(60) As String
Dim Erange4VALUE(60) As String
Dim Erange5VALUE(60) As String
Dim Srange1VALUE(60) As String
Dim taxVALUE(60) As String
Dim commVALUE(60) As String
Dim margVALUE(60) As String
Dim discVALUE(60) As String
For Each cell2 In Worksheets("RBARECT_RETAIL").Range("RBARECT_FORMULA_NAME").Cells
End Sub
Thanks for any suggestions.
I am getting an error on the bolded line. I have used Intersect successfully in other areas of my code. I think the problem is with my attempt to use the value of ExactRange1 as a Range object. In my trial, ExactRange1 becomes the name of a valid named range ("RBARECT_STYLE").
Sub RbaRectRetail()
Dim ExactRange1 As String, ExactRange2 As String, ExactRange3 As String, ExactRange4 As String, ExactRange5 As String
Dim SpatialRange1 As String, Tax As String, Comm As String, Marg As String, Disc As String
Dim lineNUMBER(60) As String
Dim Erange1VALUE(60) As String
Dim Erange2VALUE(60) As String
Dim Erange3VALUE(60) As String
Dim Erange4VALUE(60) As String
Dim Erange5VALUE(60) As String
Dim Srange1VALUE(60) As String
Dim taxVALUE(60) As String
Dim commVALUE(60) As String
Dim margVALUE(60) As String
Dim discVALUE(60) As String
For Each cell2 In Worksheets("RBARECT_RETAIL").Range("RBARECT_FORMULA_NAME").Cells
If cell2.Value <> "" Then
ExactRange1 = cell2.Offset(0, 1).Value
ExactRange2 = cell2.Offset(0, 2).Value
ExactRange3 = cell2.Offset(0, 3).Value
ExactRange4 = cell2.Offset(0, 4).Value
ExactRange5 = cell2.Offset(0, 5).Value
SpacialRange1 = cell2.Offset(0, 6).Value
Tax = cell2.Offset(0, 7).Value
Marg = cell2.Offset(0, 8).Value
Comm = cell2.Offset(0, 9).Value
Disc = cell2.Offset(0, 10).Value
For Each cell1 In Worksheets("RBA_RECT").Range("RBARECT_LINE").Cells
ExactRange3 = cell2.Offset(0, 3).Value
ExactRange4 = cell2.Offset(0, 4).Value
ExactRange5 = cell2.Offset(0, 5).Value
SpacialRange1 = cell2.Offset(0, 6).Value
Tax = cell2.Offset(0, 7).Value
Marg = cell2.Offset(0, 8).Value
Comm = cell2.Offset(0, 9).Value
Disc = cell2.Offset(0, 10).Value
For Each cell1 In Worksheets("RBA_RECT").Range("RBARECT_LINE").Cells
If cell1.Value <> "" Then
Next cell1lineNUMBER(cell1) = cell1.Value
Erange1VALUE(cell1) = Intersect(Range(Cells(cell1.Row, 1), Cells(cell1.Row, 100)), Range(ExactRange1)).Value
End IfErange1VALUE(cell1) = Intersect(Range(Cells(cell1.Row, 1), Cells(cell1.Row, 100)), Range(ExactRange1)).Value
End If
Next cell2
End Sub
Thanks for any suggestions.