Log in

View Full Version : Help with automatic filling



JVTawfiq
03-28-2013, 04:49 AM
Good day everyone.
I am new to VBA and I hope that my request for help won't be such a heavy burden.

I am asked to do the following:

I have an Excel file containing two sheets. The first one has data organised such as (Type, ISIN, Libelle,Date_Ech...)
In the second sheet, I have (ISIN, Type, Libelle, Date_Ech and other columns as well).
What the treatment must do is:
When I write the ISIN in the second sheet, I get automatically the type, libelle and date_ech corresponding to it in the columns of the second sheet.

The order of the columns in the first and second sheet is not identical. The columns aren't contiguous as well.

Any easy way to do it?
Gratefully
JVT

enrand22
03-28-2013, 10:03 AM
JVT. No it is not a heavy burden, actually it is pretty easy. i would try something like this:


sub jvt()

dim data1 as string
dim data2 as string

data1 = activecell.value 'or a specific range,

' the important thing is to know how is arrenged you information

data2 = application.worksheetfunction.vlookup(data1,sheets("sheet1").range("A:B"),2,false)

activecell.offset(0,1).value = data2

end sub



you only need to change this code acording to your workbook. This macro uses the familiar excel function VLOOKUP to take the information you want.