LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Inserting a record into multiple tables based on the Master Table.

I have a workbook with multiple tables in different tabs. One of the tabs has
the "Master Table", that has the names of the sales people in the first
column and then their data in the rest of the columns. All tables in the
other tabs have sales people in the first columns, and then different types
of data, depending on the tab.

I need to write a macro, so that when a new sales person raw inserted into
teh "Master Table", the tables in the other tabs would also update themselves
with the new sales person's name.

The challenge is that I need the raws to be sorted alphabetically. I managed
to write a macro to insert and sort it in teh "Master Table", but then don't
know how to proceed with the other tables ? Here is what I 've got so far:

Sub GetData()
Dim NextRow As Long
Dim NameEntry As String, SiteIDEntry As String, StartDateEntry As
String, _
EndDateEntry As String, RenewalEntry As String
Do
'determine next empty row
NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1

MsgBox ("Next Empty Row is row " & NextRow)

'Prompt the data
NameEntry = StrConv(InputBox("Enter the VAR Name or Cancel to
Exit"), vbUpperCase)
If NameEntry = "" Then Exit Sub
SiteIDEntry = StrConv(InputBox("Enter the VAR Site ID"), vbUpperCase)
If SiteIDEntry = "" Then Exit Sub
StartDateEntry = InputBox("Enter the Start Date as MM/DD/YYYY")
If StartDateEntry = "" Then Exit Sub
EndDateEntry = InputBox("Enter the End Date as MM/DD/YYYY")
If EndDateEntry = "" Then Exit Sub
RenewalEntry = InputBox("Is this a contract renewal?")
If RenewalEntry = "" Then Exit Sub


'write the data
Cells(NextRow, 1) = NameEntry
MsgBox ("Wrote NameEntry")
Cells(NextRow, 2) = SiteIDEntry
MsgBox ("Wrote SiteIDEntry")
Cells(NextRow, 3) = StartDateEntry
Selection.NumberFormat = "mm/dd/yyyy"
MsgBox ("Wrote and Formatted the StartDateEntry")
Cells(NextRow, 4) = EndDateEntry
Selection.NumberFormat = "mm/dd/yyyy"
MsgBox ("Wrote and Formatted the EndDateEntry")
Cells(NextRow, 5) = RenewalEntry
MsgBox ("Wrote the RenewalEntry")

'sort alphabetically
Range("A1").Select
Range("A1").CurrentRegion.Sort Key1:=Range("A2"),
Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Loop


' here would go the procedure to update table in tab1
'here would go the procedure to update table in tab2

End sub


Thanks for your help!
 
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
Multiple Pivot Tables based on the same data PEGWINN Excel Discussion (Misc queries) 3 April 13th 10 05:17 PM
PivotTable based on multiple ranges or tables Candace Excel Discussion (Misc queries) 2 January 20th 10 11:56 AM
Pivot Tables with different groupings based on same data table billwoodard Excel Discussion (Misc queries) 6 September 28th 08 01:58 AM
Pivot Tables with different groupings based on same data table billwoodard New Users to Excel 2 August 11th 08 12:41 AM
need help please inserting multiple rows based on cell value then copying to data sheet [email protected] Excel Worksheet Functions 1 July 1st 07 08:44 PM


All times are GMT +1. The time now is 08:23 AM.

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"