Link to home
Start Free TrialLog in
Avatar of zhshqzyc
zhshqzyc

asked on

Click a button to import a template

Hi, I need help. I am going to add a button on an excel file. Then by clicking it, then I can read a template(a worksheet). Need VBA codes.

Thanks.
Avatar of KnutsonBM
KnutsonBM
Flag of United States of America image

can you post the worksheet you are working with and provide a little more detail of what you are trying to do?

Brandon
Ok - here's you a starting point where it prompts you for one to many files to open.  There's an internal loop if you want to do any processing on those file(s).  This is a bit more complex than a simple file open, but readily usable to most of my applications.

Sub OpenWorkbooks()
Dim fname As Variant
Dim fnWkb As Workbook


               
        fname = OpenMultipleFilesFCN(True)

        If IsArray(fname) Then
               
            For i = LBound(fname) To UBound(fname)
                Workbooks.Open Filename:=fname(i), UpdateLinks:=2, ReadOnly:=1
            Next i
        End If
ThisWorkbook.Activate
Sheets("Control Panel").Activate

End Sub

it uses an open multiple files function set that's embedded and sourced in the 2nd module (you can open one to many or cancel out)
Cheers,

Dave
Open-Selected-Workbooks-r1.xlsm
PS - note the command button is an Active-X control that you can edit, if you go into Developer mode, you can double click on it to get to the call to the function listed in my prior post.

Please advise if further assistance is needed.

Dave
Avatar of zhshqzyc
zhshqzyc

ASKER

Okay. I attached two files. One is 384-96-Template.xls, the second one is 384-96 Conv.xls.
Now I add a button to the 384-96 Conv.xls. By clicking it, it will read 384-96-Template.xls. The 384-96-Template.xls has three columns. The 384-96 Conv.xls has five columns. The column C,D and E contains the template. What I want to is after I clicking the button, than write the template columns to the file 384-96 Conv.xls somewhere. And also add two columns which are the first column and second column, The condition is to find the row in template match the  column C,D and E.
Ex, template
Q1	g	8

Open in new window

Then
We have to write
Q1	g	8   M   15

Open in new window

384-96-Template.xls
384-96-Conv.xls
I already have some VBA code there.
ASKER CERTIFIED SOLUTION
Avatar of dlmille
dlmille
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial