creating data table

22strider

Active Member
Joined
Jun 11, 2007
Messages
311
Hello Friends

I need to create a table after applying some logic to another data table. What is the best way to go about? I am not good with arrays but have feeling that I may have to go that way. if someone can guide then I'll try to find my way through.

I wanted to post full detail of what I need to do but it was getting little hard to explain.

Thanks
Rajesh
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
22strider,

What version of Excel are you using?

Can you post the raw data worksheet, and, post the worksheet results (manually formatted by you) that you are looking for?

To post your data, you can download and install one of the following two programs:
Excel Jeanie
MrExcel HTML Maker

Or, when using Internet Explorer, just put borders around your data in Excel and copy those cells into your post.


If you are not able to give us screenshots:
You can upload your workbook to Box Net,

sensitive data scrubbed/removed/changed

mark the workbook for sharing
and provide us with a link to your workbook.
 
Upvote 0
22strider,

I looked at your other post.

I can not tell what cells, rows, columns, your raw data is in.

And, I can not tell what cells, rows, columns, your result(s) are in.


If you can not give us screenshots (per my last reply), or, you can not post your workbook (per my last reply), then:

Click on the Reply to Thread button, and just put the word BUMP in the post. Then, click on the Post Quick Reply button, and someone else will assist you.
 
Upvote 0
Hello Hiker95

I've posted tables on my original thread. I am posting them here as well. Thanks for pointing me towards the link for html maker. I've always struggled with tables not getting posted corectly.


Excel 2007
BCDEF
2Table1
3Parent PartChild PartQtyRef DesigNew Child Part
4150-0000500-681AB1C3500-681AB
5150-0000500-103AB1C4500-103AB
6150-0000500-222AB1C2500-222
7150-0000500-154AB1R3500-154
8150-0000500-1551R2500-155LF
9
10Table2
11Parent PartChild PartQtyRef DesigIsDelete
12150-0000500-681AB1C3No
13150-0000500-103AB1C4No
14150-0000500-222AB1C2Yes
15150-0000500-154AB1R3Yes
16150-0000500-1551R2Yes
17150-0000500-2221C2No
18150-0000500-1541R3No
19150-0000500-155LF1R2No
Sheet1
 
Upvote 0
22strider,

Can we have a screenshot (manually formatted by you) of what the results should look like?

Will the results be on the same/different worksheet?
 
Upvote 0
22strider,

1. Are Table1 and Table2 range names?

2. Does your Table1 reside in worksheet Sheet1, with the title Parent Part in cell B2?

3. Does Table2 already exist? If YES, what cell is the title Parent Part in?
 
Upvote 0
Hello Hiker95

1) I named Table 1 and 2 just to refer them in my request for help. They are not range names. Table1 just shows hoe the original data is formatted. Table2 shows how the result data need to appear.
2) The original data appears in one spreadsheet, the result data needs to be in another spreadsheet. Starting from any cell.
3) Table2 does not exist.

Thanks for your help
Rajesh
 
Upvote 0
Hello Hiker95

1) I named Table 1 and 2 just to refer them in my request for help. They are not range names. Table1 just shows hoe the original data is formatted. Table2 shows how the result data need to appear.
2) The original data appears in one spreadsheet, the result data needs to be in another spreadsheet. Starting from any cell.
3) Table2 does not exist.

Thanks for your help
Rajesh
 
Upvote 0
22strider,


Sample raw data in worksheet Sheet1:


Excel Workbook
ABCDE
1Parent PartChild PartQtyRef DesigNew Child Part
2150-0000500-681AB1C3500-681AB
3150-0000500-103AB1C4500-103AB
4150-0000500-222AB1C2500-222
5150-0000500-154AB1R3500-154
6150-0000500-1551R2500-155LF
7
Sheet1





After the macro in a new worksheet Results:


Excel Workbook
ABCDE
1Parent PartChild PartQtyRef DesigIsDelete
2150-0000500-681AB1C3No
3150-0000500-103AB1C4No
4150-0000500-222AB1C2Yes
5150-0000500-2221C2No
6150-0000500-154AB1R3Yes
7150-0000500-1541R3No
8150-0000500-1551R2Yes
9150-0000500-155LF1R2No
10
Results





Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
2. Open your workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


Code:
Option Explicit
Sub CreateTable()
' hiker95, 09/23/2012
' http://www.mrexcel.com/forum/excel-questions/660737-creating-data-table.html
Dim w1 As Worksheet, wR As Worksheet
Dim r As Long, lr As Long, nr As Long
Application.ScreenUpdating = False
Set w1 = Worksheets("Sheet1")
If Not Evaluate("ISREF(Results!A1)") Then Worksheets.Add(After:=w1).Name = "Results"
Set wR = Worksheets("Results")
wR.UsedRange.Clear
wR.Cells(1, 1).Resize(, 4).Value = w1.Cells(1, 1).Resize(, 4).Value
wR.Cells(1, 5) = "IsDelete"
lr = w1.Cells(Rows.Count, 1).End(xlUp).Row
For r = 2 To lr Step 1
  If w1.Cells(r, 2).Value = w1.Cells(r, 5).Value Then
    nr = wR.Range("A" & Rows.Count).End(xlUp).Offset(1).Row
    wR.Cells(nr, 1).Resize(, 4).Value = w1.Cells(r, 1).Resize(, 4).Value
    wR.Cells(nr, 5) = "No"
  Else
    nr = wR.Range("A" & Rows.Count).End(xlUp).Offset(1).Row
    wR.Cells(nr, 1).Resize(, 4).Value = w1.Cells(r, 1).Resize(, 4).Value
    wR.Cells(nr, 5) = "Yes"
    nr = nr + 1
    wR.Cells(nr, 1).Value = w1.Cells(r, 1).Value
    wR.Cells(nr, 2).Value = w1.Cells(r, 5).Value
    wR.Cells(nr, 3).Resize(, 2).Value = w1.Cells(r, 3).Resize(, 2).Value
    wR.Cells(nr, 5) = "No"
  End If
Next r
wR.UsedRange.Columns.AutoFit
wR.Activate
Application.ScreenUpdating = True
End Sub


Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm


Then run the CreateTable macro.
 
Upvote 0

Forum statistics

Threads
1,215,427
Messages
6,124,831
Members
449,190
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top