Compile Error: Expected: end of statement ? Simple code

billyheanue

Board Regular
Joined
Jul 13, 2015
Messages
109
Hi everyone again!

I have a very simple line of code : I am trying to set up a value contained in cell O59 as my col_index_value in a Vlookup. So i dont have to type the column index number in the formula, I can just use ColIndexVal.
Im getting a compile error.

Code:
Sub VertLookLiteral()

dim ColIndexVal = cells([59],[15]) as Integer




End Sub

am i referring to the cell right? Whats wronghere?

Thanks all!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Yes it is. What have you tried?
 
Upvote 0
Thanks for replying Rory! I'm still struggling in the preliminary stages of getting everything set up to do it.

Is it possible to use something like

Set Rng = Range("A37").CurrentRegion

and then refer to Rng for the "Table Array" in Vlookup? My big problem is that the Vlookup table dimensions are never definite.

Thanks, and sorry for the late reply Rory.
 
Upvote 0
Yes it is. Are you trying to put a formula in a cell or the result of the closeup?
 
Upvote 0
I'm trying to use these cell references so I dont have to define anything *strict* in the vlookup vba code.

Using this as a template, how should I go about changing the ranges from "A1:A10" notation and use my variables I set up (such as rng) instead?

Code:
Sub ADDCLM()On Error Resume Next
Dim Dept_Row As Long
Dim Dept_Clm As Long
Table1 = Sheet1.Range("A3:A13") ' Employee_ID Column from Employee table
Table2 = Sheet1.Range("H3:I13") ' Range of Employee Table 1
Dept_Row = Sheet1.Range("E3").Row ' Change E3 with the cell from where you need to start populating the Department
Dept_Clm = Sheet1.Range("E3").Column
For Each cl In Table1
  Sheet1.Cells(Dept_Row, Dept_Clm) = Application.WorksheetFunction.VLookup(cl, Table2, 2, False)
  Dept_Row = Dept_Row + 1
Next cl


End Sub

As always, Thanks a ton.

-Bill
 
Upvote 0

Forum statistics

Threads
1,223,711
Messages
6,174,025
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top