Office

     Go!
Prospero Blocks


 

Chat Center

Board Folders

MS Office - General: 4363 msgs in 880 dscns, Latest: Nov-24 MS Office - Ge...
4363 msgs in 880 dscns
Latest: Nov-24
Outlook: 10271 msgs in 1964 dscns, Latest: 11:05 AMOutlook
10271 msgs in 1964 dscns
Latest: 11:05 AM
Word & Word VBA: 9371 msgs in 1768 dscns, Latest: 7:55 AMWord & Word VBA
9371 msgs in 1768 dscns
Latest: 7:55 AM
Excel & Excel VBA: 12863 msgs in 2269 dscns, Latest: 11:14 AMExcel & Excel VBA
12863 msgs in 2269 dscns
Latest: 11:14 AM
Powerpoint: 750 msgs in 196 dscns, Latest: Sep-18 Powerpoint
750 msgs in 196 dscns
Latest: Sep-18
Access & Access VBA: 5436 msgs in 1214 dscns, Latest: Nov-6 Access & Acces...
5436 msgs in 1214 dscns
Latest: Nov-6
Graphic Tools: 130 msgs in 34 dscns, Latest: Aug-25 Graphic Tools
130 msgs in 34 dscns
Latest: Aug-25
Publisher: 254 msgs in 47 dscns, Latest: Oct-18 Publisher
254 msgs in 47 dscns
Latest: Oct-18
Works Suite: 360 msgs in 73 dscns, Latest: 5/26/09 Works Suite
360 msgs in 73 dscns
Latest: 5/26/09
Money & MSTaxSaver: 97 msgs in 27 dscns, Latest: 12/25/08 Money & MSTaxS...
97 msgs in 27 dscns
Latest: 12/25/08
MS Maps & Trips: 78 msgs in 15 dscns, Latest: Oct-23 MS Maps & Trips
78 msgs in 15 dscns
Latest: Oct-23
FrontPage: 1259 msgs in 224 dscns, Latest: Oct-15 FrontPage
1259 msgs in 224 dscns
Latest: Oct-15
Other Office Products: 325 msgs in 82 dscns, Latest: Oct-29 Other Office P...
325 msgs in 82 dscns
Latest: Oct-29
OneNote: 144 msgs in 19 dscns, Latest: Nov-11 OneNote
144 msgs in 19 dscns
Latest: Nov-11
Message Area
Excel & Excel VBA

No ides on how to dthis

 Subscribe SubscribeGet a printer-friendly version of this discussion Print Discussion 

#1 of 9

     Posted Oct-31 8:44 PM   
A1pilot
 
From  A1pilot  Posts 200  Last Nov-24
To  All      [Msg # 15893.1 ]    

This one is way out of my league and I have no clue on the best way to get this to work!

 

I have several columns of data in a sheet called P_DATA that may or may no be next to each other. I would like to find all the Numbers in a particular column and not other characters. Each column has a number (1 through 31) or a --. Then when data is found the associated pairing number is found that goes with the data number. Then that number is used to look for a number 1 through 5 and then that data is sorted one through 5.

DATA COLUMN (example is in column J)

--

--

--

1

--

--

--

--

1

--

--

...[Message truncated]
 OptionsReply to this Message Reply

#2 of 9

     Posted Nov-1 3:21 AM   
Bill Manville
 
From  Bill Manville  Posts 4156  Last 5:35 AM
To  A1pilot      [Msg # 15893.2 Message 15893.2 replying to 15893.1 15893.1 ]    

We could either attempt to use Excel formulas to achieve your goal or write some VBA macro code or combine the 2 approaches.
When formulas become quite complicated they can be more difficult to understand than the corresponding VBA.
Some results are impossible to achieve using formulas alone.
Sometimes the way we first think of doing something makes it more complicated than it needs to be,

Let's have a go.

You say you want to end up with separate tables, one for each day (from 1 to 31) containing Pairing numbers which correspond to that day in P_DATA and the value from column AP of Add_Dates in the last row for that pairing.

Let's take a look at the last bit - getting the value from column AP from the last row for pairing PA. You could use a single-cell array formula like:
=INDEX(Add_Dates!$AP$1:$AP$1000,MAX(IF(Add_Dates!$AS$1:$AS$1000=PA,ROW(Add_Dates!$AS$1:$AS$1000),0)))
where I have assumed that the data fits within the first 1000 rows of Add_Dates.  It would be better if the columns of data had range names.

It could be simpler than that though.  If the last row of the data in Add_Dates for pairing PA always contains the maximum value for that pairing in column AP then you could simply get the maximum value, MV, using array formula
=MAX(IF(Add_Dates!$AS$1:$AS$1000=PA,Add_Dates!$AP$1:$AP$1000,0))
which can be shortened, if you like, to
=MAX((Add_Dates!$AS$1:$AS$1000=PA)*Add_Dates!$AP$1:$AP$1000)

Let's also consider the requirement for separate tables, one for each day.
If you had a single table containing PA, MV and DayNo you could sort that table on DayNo and then on MV and you could filter the table on DayNo to get just the table for that day.  DayNo could be a hidden column if you prefer.
That could be simpler to construct than a number of separate tables where you don't know how big to make them or how many entries they will contain.

So, we can now get the MV value from Add_Dates to put alongside pairing PA in this composite day table.

We also need to know which day table(s) pairing PA should appear in, ie which DayNo to put alongside PA and MV.
Not clear from your example.  Does pairing PA appear in only one day table (ie with only one DayNo) or can it appear in multiple tables (ie with different DayNo values)?

If it only appears in one day table then I would deduce that there is only one number in P_DATA for that pairing.
So we should be able to find it by a Lookup function using the pairing number PA.
=VLOOKUP(PA,P_Data!$A$1:$J$1000,10,FALSE)

Hope this gives some pointers...

Bill Manville
Excel MVP/TA
Oxford, England

 OptionsReply to this Message Reply

#3 of 9

     Posted Nov-1 2:25 PM   
A1pilot
 
From  A1pilot  Posts 200  Last Nov-24
To  Bill Manville      [Msg # 15893.3 Message 15893.3 replying to 15893.2 15893.2 ]    

Wow

Let me see if I can figure out what you're saying.

Thanks for this and I will let you know if I have any questions.

A1pilotA320

Richard Hughes

 OptionsReply to this Message Reply

#4 of 9

     Posted Nov-11 1:59 AM   
A1pilot
 
From  A1pilot  Posts 200  Last Nov-24
To  Bill Manville      [Msg # 15893.4 Message 15893.4 replying to 15893.2 15893.2 ]    

Hi Bill

I’m still having problems making this work. Here is a better example of what I’m trying to do:

 

I have a column of data that contains Pairing Numbers and a table of data that has Pairing numbers and the number of days that pairing runs. If this was Access it would be a one to many relationship and I could use the access equivalence of MAX to find the maximum number of days a pairing runs.

 

So if a Pairing number in table ONE matches a Pairing number in table TWO, I need to find the MAXIMUM number of days for that Paiiring number in Table two.

 

Table ONE

 

N11

8001

N12

8005

N13

8007

I have named the ranges for the columns Pairing Number as P_Num (C6:C30) and for Actual Day as P_ActDays (E6:E30) so it really doesn’t matter what the cells are  but the entire range from the cell containing the name Pairing Number to the last cell in the row with 8010 is called P_Days (C5:e30)

Table TWO

...[Message truncated]
 OptionsReply to this Message Reply

#5 of 9

     Posted Nov-11 2:22 AM   
Bill Manville
 
From  Bill Manville  Posts 4156  Last 5:35 AM
To  A1pilot      [Msg # 15893.5 Message 15893.5 replying to 15893.4 15893.4 ]    

=INDEX(P_ActDays,MAX(IF(P_Num=N11,ROW(P_Num),0)))

You're on the right lines. The problem is with the row numbers.
P_Num starts in row 6, so ROW(P_Num) is an array {6,7,8,9,...30}
If the value you are looking for is in row 9, the index value you need into P_ActDays is not 9 but 4
This can be achieved using the array formula entered using Ctrl+Shift+Enter in O11 in table ONE, and then copied down the length of table ONE:

=INDEX(P_ActDays,MAX(IF(P_Num=N11,ROW(P_Num)-5,0)))

I don't like using -5 in the formula though because you could move the P_Days table up or down and the formula would break.
I would name the first cell in P_Days with the name P_Days_Top and then:

=INDEX(P_ActDays,MAX(IF(P_Num=N11,ROW(P_Num)-ROW(P_Days_Top),0)))

 

Bill Manville
Excel MVP/TA
Oxford, England

 OptionsReply to this Message Reply

#6 of 9

     Posted Nov-11 1:20 PM   
A1pilot
 
From  A1pilot  Posts 200  Last Nov-24
To  Bill Manville      [Msg # 15893.6 Message 15893.6 replying to 15893.5 15893.5 ]    

Hi Bill

That worked. Thanks. I never would have figured that one out.

Is there a way to see the starting points of the array so I can figure this out in the future, or do I just have to know that the tables should start in row 1 or have the offset vaule like you showed me?

Since this is an array, I don't supposed the formula can just be copied into another cell? I would assume that somehow I need to tell that new cell this formula is an array. So I can't use just:

ActiveCell.FormulaR1C1 = "{=INDEX(P_ActDays,MAX(IF(P_Num=O11,ROW(P_Num)-ROW(P_Days_Top),0)))}"

Can you please tell me the super secret macro code to tell the new cell that this formula is an array formual when I copy the formula into another cell?

Thanks again

Richard Hughes
A1pilot@flica.net

 OptionsReply to this Message Reply

#7 of 9

     Posted Nov-11 2:25 PM   
4merCL
 
From  4merCL  Posts 50  Last Nov-24
To  A1pilot      [Msg # 15893.7 Message 15893.7 replying to 15893.6 15893.6 ]    

>>  Richard Hughes
A1pilot@flica.net  <<

Hey, Richard --

Is your website what that flight crew was accessing on their laptops a few weeks ago when they overflew their destination ?    < evil grin >

 

Best regards,  4merCL

 OptionsReply to this Message Reply

#8 of 9

     Posted Nov-11 8:20 PM   
Bill Manville
 
From  Bill Manville  Posts 4156  Last 5:35 AM
To  A1pilot      [Msg # 15893.8 Message 15893.8 replying to 15893.6 15893.6 ]    

Is there a way to see the starting points of the array so I can figure this out in the future, or do I just have to know that the tables should start in row 1 or have the offset vaule like you showed me?

If you highlight ROW(P_Data) in the formula bar and press F9 you will see the array values (if that doesn't cause the formula to become too long).
Remember not to press Enter having done that or the formula will  change.

Since this is an array, I don't supposed the formula can just be copied into another cell?

You can copy the cell and paste to another cell and it will arrive as an array formula or you can fill down across a set of cells, each of which will get a suitably adjusted array formula.

I would assume that somehow I need to tell that new cell this formula is an array. So I can't use just:
ActiveCell.FormulaR1C1 = "{=INDEX(P_ActDays,MAX(IF(P_Num=O11,ROW(P_Num)-ROW(P_Days_Top),0)))}"

No, you can't use ActiveCell.FormulaR1C1 but you can use ActiveCell.FormulaArray
ActiveCell.FormulaArray =
"=INDEX(P_ActDays,MAX(IF(P_Num=RC[-1],ROW(P_Num)-ROW(P_Days_Top),0)))"
Note - you don't include the { } in the formula string, and according to help the cell reference should be in R1C1 format, (as it would have to be for setting FormulaR1C1) - although in a quick test it seems that A1 style formulas are also accepted.

Bill Manville
Excel MVP/TA
Oxford, England

 OptionsReply to this Message Reply

#9 of 9

     Posted Nov-22 3:03 AM   
A1pilot
 
From  A1pilot  Posts 200  Last Nov-24
To  Bill Manville      [Msg # 15893.9 Message 15893.9 replying to 15893.8 15893.8 ]    

Hi Bill

The Activecellformulaarray worked.

Thanks for your help with this.

Richard Hughes
A1pilot@flica.net

 

 OptionsReply to this Message Reply
 Subscribe SubscribeGet a printer-friendly version of this discussion Print Discussion 
Excel & Excel VBA

No ides on how to dthis

  
 
     

Welcome, Guest

  • Post a message
  • New messages to you
  • Log in

Start Search
Advanced Search

Prospero Blocks
 
 
Special Offers
 
 
 

Finding People

 
 
 

Cool Clicks!

 
 
 
© 2009 Netscape Communications Corp. All rights reserved.

Legal Notices | Privacy Policy