Solved

Click a button to import a template

Posted on 2011-03-17
6
246 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 42

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 42

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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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 42

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

734 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