randolphoralph
Board Regular
- Joined
- Dec 24, 2008
- Messages
- 126
I am trying to get the macro below to work.
The orginal macro was created by OssieMac and the orignal thread is located here
http://www.eggheadcafe.com/software/aspnet/33926005/macro-to-create-indexmatch.aspx
Just wanted to make sure to give credit to the creator.
The issue is that when I paste this into Excel 2010 VBA it highlights the following in red font and gives me the message "Expected Expression"
Can anyone tell me what the issue is?
The orginal macro was created by OssieMac and the orignal thread is located here
http://www.eggheadcafe.com/software/aspnet/33926005/macro-to-create-indexmatch.aspx
Just wanted to make sure to give credit to the creator.
Code:
Sub TestIndexMatch()
Dim rngDataCell As Range
Dim rngIndexArray As Range
Dim rngIndexRange As Range
Dim rngMatchRange As Range
Dim strDataCell As String
Dim strIndexArray As String
Dim strIndexRange As String
Dim lngMatchRangeCol As Long
Dim lngColToInsert As Long
Dim lngIndexArrayColMin As Long
Set rngDataCell = Application.InputBox _
(Prompt:="Select CELL in destination spreadsheet " & _
Set rngIndexArray = Application.InputBox _
(Prompt:="Highlight ARRAY in source spreadsheet to " & _
Set rngIndexRange = Application.InputBox _
(Prompt:="Highlight COLUMN in source spreadsheet where " & _
Set rngMatchRange = Application.InputBox _
(Prompt:="Highlight COLUMN in source spreadsheet where " & _
strDataCell = rngDataCell.Address(0, 0, , True)
strIndexArray = rngIndexArray.Address(1, 1, , True)
strIndexRange = rngIndexRange.Address(1, 1, , True)
lngIndexArrayColMin = rngIndexArray.Cells(1, 1).Column
lngMatchRangeCol = rngMatchRange.Column
lngColToInsert = lngMatchRangeCol - lngIndexArrayColMin + 1
ActiveCell.Formula = "=INDEX(" & strIndexArray & ",MATCH(" & _
strDataCell & "," & strIndexRange & ",0)," & _
lngColToInsert & ")"
End Sub
The issue is that when I paste this into Excel 2010 VBA it highlights the following in red font and gives me the message "Expected Expression"
Code:
Set rngDataCell = Application.InputBox _
(Prompt:="Select CELL in destination spreadsheet " & _
Set rngIndexArray = Application.InputBox _
(Prompt:="Highlight ARRAY in source spreadsheet to " & _
Set rngIndexRange = Application.InputBox _
(Prompt:="Highlight COLUMN in source spreadsheet where " & _
Set rngMatchRange = Application.InputBox _
(Prompt:="Highlight COLUMN in source spreadsheet where " & _
Can anyone tell me what the issue is?