Vba code for concatenate, vlookup

SURYAKANTHAREDDY

New Member
Joined
Sep 16, 2017
Messages
1
Hi Sir,

I am beginner in excel macro. I am able to use the macro recording. In recording we will get the formulas as is So, instead of that I want define VBA codes. So, Please help me defining the below formulas,

=CONCATENATE(C2,"-",D2)

= VLOOKUP (G2,'MASTER TEMP TL'!E:E,1,0)

= VLOOKUP(A2,'MASTER TEMP TL'!B:B,1,0)

Note : VLOOKUP need to search data in other sheet. So, here MASTER TEMP TL is sheet name.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hello,

You can make a vlookup the result of a variable or cell reference by the Application.WorksheetFunction.VLookup Method

https://msdn.microsoft.com/en-us/vb...okup-method-excel?f=255&MSPPError=-2147217396

For concatenation you just add variables, strings, or cell references. If you limit the use of ranges by using Cells(1, 1) instead Range("A1") type cell references, you save a lot of memory on larger projects:

Code:
Sub Concatenate()
' This Sub will fill Cell E2 with the value of the formula CONCATENATE(C2, "-",D2)


Cells(2, 5) = Cells(2, 3). & "-" &  Cells(2, 4)


End Sub

Hope this helps!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,984
Messages
6,175,786
Members
452,669
Latest member
reeseann

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