Click here to Skip to main content
14,926,224 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to get a excel work book created using the excel interop. I have one sheet called MonthlyBreakdowns where the values are populated from Dataset What I want now is to populate another sheet called Template with certain values from the MonthlyBreakdowns sheet

I have tried these 2 but they dun seem to give me the necessary result
VB
CType(TempWorksheet.Cells(2, 2), Excel.Range).Formula = String.Concat("=VLOOKUP(", """", "010", """", ";MonthlyBreakdown!A1:E143;5;FALSE)")

CType(TempWorksheet.Cells(2, 2), Excel.Range).Value = String.Concat("=VLOOKUP(", """", "010", """", ";MonthlyBreakdown!A1:E143;5;FALSE)")
Posted
Comments
Maciej Los 11-Aug-15 9:21am
   
What's error message?
ASJ_SA 11-Aug-15 10:29am
   
no error message.. just doesn't do anything!!
Maciej Los 11-Aug-15 11:50am
   
Paste here the exact formula
ZurdoDev 11-Aug-15 11:41am
   
Your VLookup looks wrong. I suggest first make it work in regular Excel, then write it in code.

1 solution

First, manually write your formula in a cell, make sure it works.
This is the model for the vb code.

Then, store this formula embedded in quotes as a formula into a cell.

Adice: look at tutorials for "VBA for Excel"
To know how to do something that you do manually, record a macro while you type it, then look how the macro recorded it, it should give you hints about how to do.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900