ANmarS - Search results

Excel/VBA expert since Sep 1997 (20 years 9 months)

We are moving ...

We are moving to another location, better, faster and more resources .... check it out ANmar.Systems

5 Q & A posts tagged with OFFSET

Mon
Apr 12
2010

How do I remove blank (but not necessarily empty) cells from a drop down menu in excel?

I want to have a row of drop down lists. In each drop down I want all the options to exist EXCEPT any that have already been selected. This is my primary problem. The closest I can get is to remove value from the drop down range by an IF function in the source data, so that the list updates based on what has already been selected. This requires extensive functions and also leaves blanks in my drop down menus. I'm keen to have the drop downs only contain the remaining options and no blank gaps. Are there any solutions to either the primary problem, or, failing that, a solution to remove the blank (but not empty) cells from my drop down menus?

Cheers :)


Answer

You have very interesting request

Check out this file
http://www.File1.net/Links/NewList.xls

It has new list populated every time user selects an item, the new list will have the same as old list without the newly selected one, it was done for tutoring purposes

It should do what you are looking for, you might need some tweaks though
That was done using the following Excel features:
Data Validation
OFFSET function
IF function
Name

Let me know if it helped or not

VBAXLMan

Monday 4/12/2010 2:35:47 AM
Sun
Apr 4
2010

Create an automatic table based on the past three months?

hi, i have an excel sheet with the past five years data on it. Each row represents a month so each month it gets one row longer.

I already have a defined range that selects the most recent 3 months, but i need to know how to display the last 3 rows and the field headings on another sheet in a specific position by the click of a button(macro).

I can make a line graph using the last three rows of data with just a click of a button and now i want to show the data used underneath the chart.

Thanks for all answers


Answer

You don't need a macro to do that
You can make it in Formulas which means faster, auto updated, etc

Let's start with some assumptions:
- You have two sheets (Sheet1 has the full data and Sheet2 to have the last three months)
- In Sheet1, your data starts from cell A1 along to V1, with headers in first row and the data below it.
- In Sheet2, you want the last three months to be in A2 to V2, A1 to V1 has the row headers

Now, in Cells A1:V1, just copy the headers (you need to do that once)
In cell A2, paste this
=OFFSET( Sheet1!$A$1,COUNTA( Sheet1!$A:$A)-ABS(ROW()-1),COLUMN( )-1)

Then copy A2 along to V2, then copy Row2 into Row3 and Row4

These three rows will bring you the last three rows from your table in Sheet1 assuming you don't have any empty cells in that table in column A
And when you add new values at the end of that table in Sheet1, these will automatically updated

Does that make sense?

let me know

VBAXLMan

Sunday 4/4/2010 11:13:43 AM
Thu
Apr 23
2009

Excel > Use formulas on the last x rows of data?

I'm keeping track of the total number of wins and losses for a sports team. There's one game a week. I will have 16 rows in my Excel sheet to mark a win or loss. If the team wins that week, I'll put in "W" for that week's row, and "L" for a loss. As you can imagine, a new row will be populated with either a "W" or "L" as the weeks progress.

I'm trying to get a win/loss count of the last 5 games played. So if the team has played 7 games, I want to show the total number of wins and losses of the last 5 games (games 3-7). If 10 games have been played, then show the total number of wins and losses for games 6-10. This is similar to the L10 statistic for baseball, hockey, and other sports, but in this case, I'm trying to do a L5 for the last five games.

How can I achieve this in Excel? I'm going to use COUNTIF for counting the total number of "W" and "L", but I need it to count only the last five rows of data.

Any help is appreciated. THANKS!


Answer

Do this so that whenever you add new row/week it will automatically updated

Now, if your list of Ws/Ls starts from A2 down, paste this in D1
=COUNTIF( OFFSET(A2, COUNTA(A:A)-6,0,5,1),"W")
To get the number of Ws in the last 5 non empty cells in Column A

And do this in E1
=COUNTIF( OFFSET(A2, COUNTA(A:A)-6,0,5,1),"L")
To get the number of Ls in the last 5 non empty cells in column A

Also assuming you have the cell A1 with text as header

Good luck


VBAXLMan

Thursday 4/23/2009 4:19:56 PM
Mon
Jan 19
2009

Can you help me with my Excel question?

I have people send me a lot of reports that were created through AIX access. I usually take those reports and dump it into Excel, where I do some formatting afterward. A problem that I run across every now and then, is when I hit a multi-valued field and the information is displayed vertically... like so (I will put in which cell it would fall into next to the value)

A1 - [patient 1] B1 - [perscription number 1]
B2 - [perscription number 2]
B3 - [perscription number 3]
A4 - [patient 2] B4 - [perscription number 1]
B5 - [perscription number 2]
A6 - [patient 3] B6 - [perscription number 1]

and so on, and so on...

Is there any way to get those values to move to be displayed on line like so

A1 - [patient 1] B1 - [perscription number 1] C1 - [perscription number 2] D1 - [perscription number 3]
A2 - [patient 2] B2 - [perscription number 1] C2 - [perscription number 2]
A3 - [patient 3] B3 - [perscription number 1]



I appreciate any assistance you can give, and I apologize if I've made my own question sound more complex than it has to..


Answer

Yes, you have two solutions:
1- Using macros, which sounds to me in your situation faster and easier
2- Using formulas, but this will be kind of duplicated formula (or set of formulas)

Now, I want you to answer some questions:
1- How many is the maximum number of drugs per patient you can expect?
2- The formula below, can work in cells C1, D1 and E1 and below, but the problem will be deleting the empty rows, if you answer Q1, then I think I can do that also
Now paste this in C1
=IF( $A1="","",IF( OFFSET( $A1,COLUMN( )-2,0)="",$B2,""))
And this in D1
=IF( $A1="","",IF( OFFSET( $A1,COLUMN( )-2,0)="",$B3,""))
And this in E1
=IF( $A1="","",IF( OFFSET( $A1,COLUMN( )-2,0)="",$B4,""))

then copy those three down

I told you it is a complicated, now these three will transpose your rows into columns
You will still need to delete the empty row, I could delete them using formulas, but I needed more details as I told you

Enjoy my profile, VBAXLMan is back to feed your Excel needs

Monday 1/19/2009 8:44:10 AM
Mon
Jan 19
2009

I want column to change by not the row in excel or google doc?

My formula looks like this

='Activity sheet'!C$1
='Activity sheet'!C$1
='Activity sheet'!C$1

I want it to be

='Activity sheet'!C$1
='Activity sheet'!D$1
='Activity sheet'!E$1
='Activity sheet'!F$1

etc.

Help will be more appreciated.


Answer

Sure, do it like this

Now this will depend on where you are putting it:
So Assuming you want to put this in cell A1 and down, then paste this

=OFFSET( $C$1, 0, ROW()-1)

And fill it down

Yes, I know, I am the VBAXLMan here

Monday 1/19/2009 6:41:27 AM

Tags

History