Trying to create a custom solution in Excel, and everybody in the office is stumped.
The Excel document has three worksheets, called MASTER, DATA1, DATA2. All three worksheets have the same columns, in the same locations. Only thing different is DATA1 and DATA2 have different info listed in their rows.
What we want to do is have the MASTER sheet display content from both DATA1 and DATA2. The trick is that data will be updated in DATA1 and DATA2 regularly, additional rows of content will be added over time.
How do we get this type of content to properly display in the MASTER sheet? We need MASTER to be dynamic enough to "add" rows from DATA1 and DATA2, or even delete rows from either of those sheets...all without overwiting data from the other worksheet. We can "reserve" a number of rows in MASTER, but we'd like to have it list all the rows from one, then all the rows from the other, if at all possible.
Help? Thank you!
Last edited by klamen; 01-14-2010 at 10:24 AM.
If you put all the data into MASTER you could then make some of it appear in DATA1 and some in DATA2, just by having an additional column in MASTER
May be more practicable in the long term.
CC
You would need code to copy the data from each sheet to the master.Would you clear existing data from the incoming sheets or h=just keep adding them?
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
The incoming sheets (DATA1 and DATA2) may have additional rows of content added over time, but the columns would never change in any of the worksheets. We would like to be able to delete rows of content if needed, but if that is not possible, we can color fill the data fields on the DATA sheets so on the MASTER it shows that those row issues are already resolved.
We can "copy/paste" to MASTER, but with 20 employees accessing DATA1 and DATA2 (and perhaps more worksheets), somebody's going to forget to manually update the MASTER worksheet.
Here's the issue we have. If currently DATA1 has 5 rows of data, and DATA2 has 5 rows of data, it's easy to get that copied over automatically to MASTER. Problem is as soon as we add two rows of data to DATA1, it now has 7 rows of data to copy to MASTER. Now, this "overwrites" the data coming from DATA2 into MASTER, and none of it shows up.
So, is there a way to automatically place an empty row in MASTER, that keeps the info from DATA1 an DATA2 separated? So if DATA1 has more rows added, it will simply go to MASTER (no matter how many rows are there), the "buffer empty row" is there, and then the data from DATA2 goes into MASTER? This would keep the data visible on Master, but not allow for additional rows in the DATA sheets to overwrite the other.
Au contraire, my dear Roy.
We could create a query to reference the other tables (we would need to name them) and use union (or union all) to append the two sheets' worth of data...
Are you willing to try this, klamen? It takes a little while to explain and I don't want to waste my time!
CC
I'm willing to try anything at this point, CCYou would think this would be something very simple with a copy function, but guess nobody else at MS thinks consolidating info onto a master is important
Thanks!
By the way, I've got a test file with what I'm trying to do...just can't figure out how to get it attached here on my forum postings.
EDIT: UPLOADED SAMPLE XLSX file
Last edited by teylyn; 01-22-2010 at 04:39 PM. Reason: quote removed
When you're editing a post, click "go advanced" and underneath the main edit window is a "manage attachments" area - use that. If you upload a nice simple example I will be able to walk you through the steps much more easily.
CC
Thanks, edited my response above with the test document. All I want is to get everything from DATA 1 and 2 (and other future additional sheets) into MASTER, no matter how many rows there are in each of the sheets
I do appreciate your helping me along!
Last edited by teylyn; 01-22-2010 at 04:39 PM. Reason: quote removed
Still looking for ideas.
Maybe it's not the best option but it works. I've uploaded workbook.
Private Sub MasterButton_Click() Dim Db1, Db2 As Worksheet Dim MyDb1Rng, MyDb2Rng As Range Dim lRow, lstRow, lsRow As Long Set Db1 = Sheets("DATA1") Set Db2 = Sheets("DATA2") Application.ScreenUpdating = False 'Finding last row in DATA1 sheet With Db1 lRow = .Cells(.Rows.Count, 1).End(xlUp).Row End With 'Finding last row in DATA2 sheet With Db2 lsRow = .Cells(.Rows.Count, 1).End(xlUp).Row End With 'Finding lastrow in Master sheet With ActiveSheet lstRow = .Cells(.Rows.Count, 1).End(xlUp).Row End With 'Clearing Contents of used range in master sheet Sheets("Master").Range("A2", "H" & lstRow + 1).ClearContents 'Setting up and copying DATA1 used range and pasting copied range into Master sheet. Set MyDb1Rng = Db1.Range("A2:H" & lRow) MyDb1Rng.Copy Sheets("Master").Range("A2").PasteSpecial (xlPasteValues) Application.CutCopyMode = False 'Setting up and copying DATA2 used range and pasting copied range into Master sheet. Set MyDb2Rng = Db2.Range("A2:H" & lsRow) MyDb2Rng.Copy 'Finding lastrow in Master sheet With ActiveSheet lstRow = .Cells(.Rows.Count, 1).End(xlUp).Row End With Sheets("Master").Range("A" & lstRow + 1).PasteSpecial (xlPasteValues) With Application .CutCopyMode = False .ScreenUpdating = True End With End Sub
Люди, питающие благие намерения, как раз и становятся чудовищами.
Regards, «Born in USSR»
Vusal M Dadashev
Baku, Azerbaijan
Contaminated,
In these declarations,
... everything except the last variable on each line is a Variant. What you want isDim Db1, Db2 As Worksheet Dim MyDb1Rng, MyDb2Rng As Range Dim lRow, lstRow, lsRow As Long
Dim Db1 As Worksheet, Db2 As Worksheet Dim MyDb1Rng As Range, MyDb2Rng As Range Dim lRow As Long, lstRow As Long, lsRow As Long
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
shg
I'm really new in VBA and I can make a mistake. So thank you for correction.
Briefely for the future: I must dim worksheet and range separately? Right.
I don't want to arque, but the code works, so why to change smth?
I know I'm wrong here by asking that, but I just want to understand
thx in advance...
Люди, питающие благие намерения, как раз и становятся чудовищами.
Regards, «Born in USSR»
Vusal M Dadashev
Baku, Azerbaijan
You must specify the data type for each variable, else the variable defaults to a Variant.
You don't have to declare variables at all; it's just good practice. It enables VBA to detect type mismatches, and avoids unnecessary errors.I don't want to arque, but the code works, so why to change smth?
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks