I'm tired of merged cells. They just don't work.
So I found a way to avoid merging cells horizontally, when I just need my text to be centered across multiple columns. That's: Range("A1:C1").HorizontalAlignment = xlCenterAcrossSelection.
It works like a charm. It's perfect. It's just what I needed.
I oh-so-naively thought you could do the same vertically, for centering text over multiple rows. Something like: Range("A1:A3").VerticalAlignment = xlCenterAcrossSelection.
But alas, that doesn't work.
Am I missing something here, or did Excel developers really think that, while centering across columns is a common deal, centering over rows is so much of a silly idea nobody would ever do that so why even bother?
You can try this:
Sub VerticalAlign()
ThisWorkbook.Sheets(1).Cells(Round((WorksheetFunction.CountA(Range("A1:A6")) + WorksheetFunction.CountBlank(Range("A1:A6"))) / 2, 0), "A") = "Your Value Here"
End Sub
You'll need to change the ranges being counted, and the column it's referring to, but that should just about do it. A little warning, though: VBA does NOT round the same way that Excel does. It should always be within one digit, though. You can read more about that here: http://support.microsoft.com/kb/194983
We use textbox shapes over cells to do this. If you hold Alt while drawing out the shape, the corners will snap to the Excel grid and move and size with the cells, so it doesn't take much more time than typing into the cells.
I found a happy accident that works around my issue on this if anyone cares to know.
For my situation I needed to track employee vacation time on a linear calendar that was sort-able by name and responsible area. The title section covered three rows that i wanted visible when the data below was filtered. Row 1 = years (merged across months), Row 2 = months (merged across days), Row 3 = days.
Cells A1:A3 was merged and labeled Names (employees), B1:B3 merged and labeled AREA (responsibilities) so we could track vacation time on a calendar spreadsheet to make sure each area had coverage (at least one employee responsible for it was available). The downside of this method caused the filter blocks to be associated with row 1, so row 2 and 3 were hidden when names were filtered on.
Then I tried the VBA code from previous post and it worked, but maxed out at font size that would fit, if too big it would be cut off. So Aesthetically, it looked bad.
Then I put the Names/Area titles in cells A3 and B3 without merge and set filters on row three. This filtered everything starting at row 4 effectively without hiding anything above it, but still looked bad.
Now I found the work around. If you have your titles in the top cell of where you want to merge, and some value in the bottom section. Set filters on the bottom section (need a value to set filters). Then merge the three cells, it works.
So now my A1:A3 Name, and B1:B3 Area is merged, but the filter boxes are on the bottom of the sections (aligned with row 3).
Hopefully that works for some people. I then locked those cells from edit (except auto filter settings) and now it cant be changed accidentally. only filtered.
Related
I have an excel form which displays a six generation family pedigree chart. Each box for a person's data is merged together from 3 columns and 7 rows. 4 lines of text fit into each box, the 1st line is name, the 2nd birth date and place, the 3rd marriage date and place and the 4th death date and place.
The rightmost two columns are the triple great grandparents of the root person and sometimes a 2nd chart is needed to show their ancestors. The 2nd chart tile is Chart mm-nn where mm is the chart number where the person appears as a GGG grandparent and nn is their number in that chart.
How can I put a number in the upper right corner of these boxes in my chart?
I thought of appending the number to the person's name and flush it right. If possible, it must be with some exotic format string. But each box has 4 text lines and the flush right formatting needs only apply to the 1st.
Perhaps make the numbers as little graphics and overlay them? Chop up the base cells even smaller and merge them into 4 separate lines with the 1st line shorter than the others with a small number box at the end of it?
Ideas?
Jim
The short answer to your question is: no, that's not possible. This is Excel not MS Word. Hence, you can set any given cell only to be left-justified or right-justified. You cannot have both for one cell.
Yet, maybe any of the following work-around might be of help in your case. Of course, I can't be sure since you haven't provided any screenshots of the desired out-come (like a mock-up). But here we go:
This is where you are coming from. A merged box of three columns by seven rows containing four lines of text.
(1) One solution might be to have three different merged areas. The following example consists of three merged areas. The first two rows and the first two columns make up the name. The last column on the first two rows is merged to contain the number and the rest is one merged box again containing the dates and the places.
Note, that you can only see the difference to the original since I selected in this example the top right merged area (consisting of the number only). Otherwise, there wouldn't be any (visually apparent) difference.
(2) Another solution could be to manually insert as many spaces after the name as necessary to make it seem as if it were right-justified. The problem here is (of course) that this changes with the font, the font-size, if the font is bold (or italic) or not, and also the current zoom-factor for the sheet. Hence, this solution would soon wear you out as you would have to manually adjust all the cells constantly. I just wanted to point out this solution for the sake of completeness.
(3) The following solution consists of a text box shape on top of the cell. So, basically I am leaving your original cell (consisting of three columns and seven rows) as is and simply put a shape on top of that cell. The following screenshot shows the result in the top part and the text box being selected in the bottom part (so you can see how this one comes together).
(4) The following work-around is probably the solution you've been looking for and you want to go with. This one is moving away from the cells on the sheet and relies only on text-boxes which are shown on top of the sheet (and thus on top of the cells). Here you can "merge" several text boxes into a group. The group will move and size as a whole. At the same time this group consists of several text boxes and as such may consist of left-justified text boxes and right-justified text boxes as you can see in the screencast below.
I'm working on a personal budget spreadsheet, and I have a tab that calculates what I've spent so far in certain categories and compares that total to what I have budgeted for. I have one column showing how much I've spent and the one next to it shows how much I have left to spend. What I want to do is highlight both the total and the amount left if the column showing the difference is negative. I want to do this for the whole 2 columns. Here is a link to my sheet:
https://docs.google.com/spreadsheets/d/1AXaxVpVpblxwnS7VBhz4yhz1SNXRGCB6Zrb3OIKiaKk/edit?usp=sharing
I think my main challenge is highlighting both cells dependent on only one of them. I've tried some custom formulas but they don't seem to work. I know there has to be a way to do this. Any ideas?
You just need to fix the custom formula with a $ and apply it to G6:H26 so that when it is applied to column G it still checks column H:-
=$H6<0
Hope that helps
I have an excel sheet that gets dumped out from a model I use. Unfortunately, I have to take a lot of time by hand to fix these sheets every day. However, it can be really easy to work with if this one change is made.
I attached a picture, the left is what it comes out of the model as, the right is what I would like it to be like in a new sheet. The only problem I foresee is the number of values in the second column is different every time, so the labels in the first column aren't always in the same place.
Any ideas on how to accomplish this would be appreciated. Picture
Fill in the first cell by hand and then just autofill this easy formula:
F3=IF(F3<>"";F3;F2)
I am creating an excel workbook with finances for a company. In this workbook is a sheet with the income statement and a sheet with parameters.
In the sheet with parameters is a cell with the number of quarters how long a service contract of a product of the company is expected to last.
In the sheet with the income statement I want to sum as much cells as the number in the parameters sheet.
e.g. "Parameter"-sheet cell B7 has the number 4. Now in the "Income statement"-sheet I want the sum from cells C8 to 4 columns to the right (because Parameters!B7 = 4). But if I change the number in Parameters to 5 it has to take automatically 5 columns to the right in the Income statement.
I have tried with changing my Excel to R1C1, but I have no clue how to create this. With or (if possible) without VB.
It has to be something like this:
=SUM(R8C3:R8C[+Paramaters!R7C2])
There are a couple of ways of doing this. The first would be offset. Your offset formula is based off this format.
OFFSET(REFERENCE CELL, NUMBER OF ROWS TO MOVE, NUMBER OF COLUMNS TO MOVE, HOW MANY ROWS TO RETURN FROM THE NEW POINT, HOW MANY COLUMNS TO RETURN FROM THE NEW POINT)
Positive moves your down or to the right. Negative values move your left or up.
So in your case you would be looking at something like:
=SUM(OFFSET($C8,0,0,1,'Parameters'!B7))
Now I did not lock the 8 in case you were planning on copying down and wanted a new row for each line you copied down and did not want C8 to always be the same reference point. However there are ways around that and keep $C$8 if you prefer.
Now having said that, if you are just using offset a few times, by all means go ahead it wont slow things down. However if you are using it quite frequently, it will slow things down as it is a volatile function that will recalculate anytime any information is changed on the worksheet.
Now to get around that we have options!
You could also go with the INDEX option. The index option, since it returns a cell address behind the scenes, could be used as follows:
=SUM(C8:INDEX(8:8,COLUMN(C8)+'Parameters'!B7))
Earlier this week, I asked a question about getting an area chart to drop off vertically instead of diagonally when I don't have enough data for some series.
https://superuser.com/questions/809955/excel-2010-area-chart-drop-off
teyley's answer works really well, that's exactly what I wanted. However, there is now some situations where I will have data for February to August for example but no data for January (because the employee wasn't yet in the enterprise at this moment for example).
It does create a diagonal drop off at the beginning of the chart again even though January's data are set to NA(). Using teyley's answer, I can get dynamic ranges for the series, but it still has to be progressive, the first row of data will always be January using that method. What to do if the data for a specific series actually starts on February?
So, assuming I have data for February to August, using teyley's example and answer, how could I make it so that there is a vertical drop off in February instead of a diagonal going down to 0 on January?
Here is the formula for the dynamic named range:
FirstSeries = OFFSET($B$1,1,0,COUNT($B:$B),1)
Then, I use this in the chart for each series as shown in my earlier question:
=SERIES($B$1,$A$2:$A:$A13,Book1!FirstSeries,1)
I got this answer from another forum, but I've been looking quite a while for the answer, so I'll post it here as well. The original thread can be found here:
http://www.excelforum.com/showthread.php?t=1024240
make your category axis into dates (not text or select automatically)
insert a row in your excel sheet for the date where you want the cliff (move values down) and repeat that date. In your case your Date column will read: Jan, Feb, Feb, Mar, Apr, May etc, and you don't have to add any values in the cells that are created next to Feb in the One, Two, Three, and AxisSpacer columns.
I haven't researched how you can apply this with dynamic named ranges.
As Sean Cheshire pointed out in the comments, one solution is to add white squares over the diagonal area at the beginning. There are probably multiple ways to do this. What I've done is creating a new series in the chart but instead of using areas, I'm using white bars with no shadows/borders and with no spacing. That said, there is another problem: the bars are centered on the X-axis. It means that the white bars will either cover half of a month or will be half a month short. To get around this problem, I added another series of white bars. That way, with 2 bar series, the bars aren't centered anymore, I just have to make sure to put the bars in the right place by putting the right numbers (0 or 1) in the white series.
It is not really elegant but it's still a solution.
I was able to get a chart without a dropoff on the right (showing blank spaces), by using a "Placeholder" row that has a value of 0 across all columns.
Select the area you want on your table (notice, do NOT include empty/null cells)
Create the Area Chart, using that selection, and click Select Data to modify some values. Click Edit to update the Horizontal (Category) Axis Labels, highlight your column headers again and click OK so you see them listed in the right panel, then uncheck the "blank series" in the left panel. You need to keep Placeholder checked to show your empty columns to the right of your data.
Finally, select and delete the Placeholder label in the legend, so it's as if it isn't there.