Solved

Click a button to import a template

Posted on 2011-03-17
6
243 Views
Last Modified: 2012-05-11
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.
0
Comment
Question by:zhshqzyc
  • 3
  • 2
6 Comments
 
LVL 6

Expert Comment

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

Brandon
0
 
LVL 41

Expert Comment

by:dlmille
ID: 35158718
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
0
 
LVL 41

Expert Comment

by:dlmille
ID: 35158726
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
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:zhshqzyc
ID: 35158979
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
0
 

Author Comment

by:zhshqzyc
ID: 35158988
I already have some VBA code there.
0
 
LVL 41

Accepted Solution

by:
dlmille earned 500 total points
ID: 35159822
I posted a solution that met the OP objective, and ahead of the OP finding a solution on his/her own.  Some consideration of Asker even in the form of explanation is desired, given the time spent trying to give a helping hand.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now