Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automatically pull data from one file to populate a template


Hi Everyone...
Just beginning to get the hang of vba coding in excel. I would like
to implement a new feature in a spreadsheet here at the office. We
currently have a master records sheet containing vital information on
unit processing. Each unit then has a sub file containing additional
information. Currently one must populate the master record file. Then
open a template and populate another file with the same information. I
would like to streamline this process and have the data in the master
record file automatically inserted into the template, allowing the user
to only have to fill in a few other minor details. What I would like is
to have a "Create Record" button. When clicking the button the user
should be prompted for either a record number (stored in the B column)
or a row number (not as elegant). The macro would then pole that row (x)
and transfer the value of cells BX, CX, DX, etc to cell A3, D9, E6 etc
in the newly created file based on an existing template (template.xlt)
Any help would be greatly appreciated as I am lost when it comes to
something this complex.


--
jmootrey
------------------------------------------------------------------------
jmootrey's Profile: 1387
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=170486

Microsoft Office Help

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Automatically pull data from one file to populate a template


I have assumed that your data file is named

Master Record.xls

and that the data is on a sheet named

Data Sheet

and that your template has a sheet named

Report Sheet




In your template's VBA project, insert a userform with a listbox and a commandbutton - named
Userform1, Listbox1, and Commandbutton1.

Then, use code like this (stored in a regular codemodule) to allow the user to select the record
number:

Sub SelectRecordNumber()
With Workbooks("Master Record.xls").Worksheets("Data Sheet")
UserForm1.ListBox1.List = .Range(.Range("B2"), .Cells(Rows.Count, 2).End(xlUp)).Value
End With
Load UserForm1
UserForm1.Show
End Sub


Double click the commandbutton, and use this code for the click event

Private Sub CommandButton1_Click()
Dim i As Integer
Dim Sel As Boolean
Dim myRow As Double
Dim myR As String

Sel = False

For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
MsgBox "You selected " & ListBox1.List(i)
myR = ListBox1.List(i)
Sel = True
Exit For
End If
Next i

If Sel Then
With Workbooks("Master Record.xls").Worksheets("Data Sheet")
myRow = Application.Match(myR, .Range("B:B"), False)
'Bring over the data
ThisWorkbook.Worksheets("Report Sheet").Range("A3").Value = .Cells(myRow, 2).Value 'from
column B
ThisWorkbook.Worksheets("Report Sheet").Range("D9").Value = .Cells(myRow, 3).Value 'from
column C
ThisWorkbook.Worksheets("Report Sheet").Range("E6").Value = .Cells(myRow, 4).Value 'from
column D
End With
Unload UserForm1
Exit Sub
End If
MsgBox "Select something!"
End Sub

I hope you can see the pattern for the data transfer.....

HTH,
Bernie
MS Excel MVP


"jmootrey" wrote in message
...

Hi Everyone...
Just beginning to get the hang of vba coding in excel. I would like
to implement a new feature in a spreadsheet here at the office. We
currently have a master records sheet containing vital information on
unit processing. Each unit then has a sub file containing additional
information. Currently one must populate the master record file. Then
open a template and populate another file with the same information. I
would like to streamline this process and have the data in the master
record file automatically inserted into the template, allowing the user
to only have to fill in a few other minor details. What I would like is
to have a "Create Record" button. When clicking the button the user
should be prompted for either a record number (stored in the B column)
or a row number (not as elegant). The macro would then pole that row (x)
and transfer the value of cells BX, CX, DX, etc to cell A3, D9, E6 etc
in the newly created file based on an existing template (template.xlt)
Any help would be greatly appreciated as I am lost when it comes to
something this complex.


--
jmootrey
------------------------------------------------------------------------
jmootrey's Profile: 1387
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=170486

Microsoft Office Help



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
User form caption automatically populate with excel file name Steve Excel Programming 2 October 17th 06 11:44 PM
Looping through data and Populate template nxqviet Excel Programming 1 October 5th 06 12:34 AM
automatically populate fields from the source file Mir Khan Excel Programming 1 May 9th 06 02:04 AM
How can you have data automatically populate btw workbooks kzparham Excel Worksheet Functions 2 December 2nd 05 07:04 PM
Automatically pull data into another worksheet within the same fil TJess Excel Worksheet Functions 1 November 15th 04 08:00 PM


All times are GMT +1. The time now is 04:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"