Showing posts with label expert. Show all posts
Showing posts with label expert. Show all posts

Thursday, 29 January 2015

Microsoft Word 'Document Map' Bug and work around

When I am working with a huge word document, I find using a 'Document Map' very convenient to navigate the whole document. However, there is one bug, which is persistent and annoying as hell. Thankfully there is a work around which I will explain in this post.

If you are unfamiliar with Document Map, please read my earlier post on Document Map (http://mad-exceltips.blogspot.com/2014/04/microsoft-word-document-map.html). 

With a document filled with content and Document Map enabled, originally looks like this
Document Map in Microsoft Word
However, when you close and open the document, the Document Map jumbles up as below. 
Jumbled Document Map after re-opening the document
Before knowing the workaround, I have reorganized the Document Map numerous times, before I got annoyed and looked for a workaround. The work around doesn't really fix the bug, but if you follow few practices, the Document Map will remain the same. 

The issues is, Word re-formats the document when you re-open the document. Keep an eye on the bottom right (left of zoom options), when you open the document. First, Word says 'Opening' then jumps to 'Word is formatting the document'. If it says, 'Word is formatting the document' that is when the bug is introduced. And after the document is opened, the Document Map will look all jumbled up.

The workaround is

  1. The moment, you see 'Word is formatting the document'; do not save the document. If you save it, the new format will be saved. 
  2. Instead, go to View -> Un-check Document Map
  3. Close the document without saving it.
  4. Re-open the document. Now, it shouldn't say 'Word is formatting the document'. If it still does, do mail me. We will figure out a workaround.
  5. After you open the document, go to View -> Check Document Map. Bingo !! The map is intact. 
Any deviations, from what I described above; or better workarounds, please do mail me. Would be happy to listen.

Hope that helps,
Ramada


PS: please feel free to drop you excel/ word/ power point queries to mad.exceltips@gmail.com. I will try and respond as soon as I can. The more curious your question, the faster I respond.

Tuesday, 20 May 2014

Bubble Chart with Text inside the bubble

Bubble chart is a concise and crisp way of presenting data with 3 dimensions. However the main challenge of creating a bubble chart is; 'to have the text (names/ regions/ countries/ products) within the bubble'

Assuming we have 4 people data of Age, Weight and Height. The data is as below

AgeWeightHeight
John28707
Michael50346
Vicky34608
Neil152710

If we create a bubble chart by selecting this data we get something like below

Basic bubble chart with data labels

It is very difficult to determine which bubble belongs to which person. And to enter the persons name into the bubble charts, there is no automatic way in excel. Depending on the number of rows, this task can be very tedious and time consuming.

Thankfully, the bubble chart VBA code (provided at the end) can do this in a click. Follow the below steps

  1. Open a new excel workbook, 
  2. Press Alt F11. This takes you to Microsoft Visual Basic Editor
  3. Copy the below VBA code from "Public Sub... End Sub" and paste it into the above opened window
  4. Close the VBA editor.
  5. In the workbook, go to Insert -> Shapes -> Select a Rectangle. Draw a rectangle on your sheet. 
  6. Right click the rectangle, and click Assign Macro. From the list, select a row which ends with CreateBubbleChart2. This makes the rectangle shape a button. Try clicking it. It should say 'Selection must have 4 columns and at least 2 rows'. If you see this message, Bingo !! its working. 
  7. To test this, copy paste the table provided above. Select the data (4 columns and 5 rows) and click the rectangle. This should create a bubble chart as below in a new sheet.
  8. When you close, make sure you Save As 'Excel Macro-Enabled Workbook' (this selection can be found just below the space where you enter file name. 
Bubble chart created using the VBA code below


















Hope this helps.
-Ramada

PS: please feel free to drop you excel/ word/ power point queries to mad.exceltips@gmail.com. I will try and respond as soon as I can. The more curious your question, the faster I respond.

Public Sub CreateBubbleChart2()

    If (Selection.Columns.Count <> 4 Or Selection.Rows.Count < 3) Then
        MsgBox "Selection must have 4 columns and at least 2 rows"
        Exit Sub
    End If

    Dim SelectedRange As Range
    Set SelectedRange = Selection

    Sheets.Add After:=Sheets(Sheets.Count)

    Dim bubbleChart As ChartObject
    Set bubbleChart = ActiveSheet.ChartObjects.Add(Left:=1, Width:=600, Top:=1, Height:=400)
    bubbleChart.Chart.ChartType = xlBubble
    Dim r As Integer
    For r = 2 To SelectedRange.Rows.Count
        With bubbleChart.Chart.SeriesCollection.NewSeries
            .Name = "=" & SelectedRange.Cells(r, 1).Address(External:=True)
            .XValues = SelectedRange.Cells(r, 2).Address(External:=True)
            .Values = SelectedRange.Cells(r, 3).Address(External:=True)
            .BubbleSizes = SelectedRange.Cells(r, 4).Address(External:=True)
        End With

    Next

    bubbleChart.Chart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
    bubbleChart.Chart.Axes(xlCategory, xlPrimary).AxisTitle.Text = "=" & SelectedRange.Cells(1, 2).Address(External:=True)

    bubbleChart.Chart.SetElement (msoElementPrimaryValueAxisTitleRotated)
    bubbleChart.Chart.Axes(xlValue, xlPrimary).AxisTitle.Text = "=" & SelectedRange.Cells(1, 3).Address(External:=True)

    bubbleChart.Chart.SetElement (msoElementPrimaryCategoryGridLinesMajor)
    bubbleChart.Chart.Axes(xlCategory).MinimumScale = 0

    ActiveSheet.ChartObjects(1).Activate
    Dim srs As Series
    For Each srs In ActiveChart.SeriesCollection
        srs.ApplyDataLabels AutoText:=True, LegendKey:=False, _
            ShowSeriesName:=True, ShowCategoryName:=False, ShowValue:=False, _
            ShowPercentage:=False, ShowBubbleSize:=False
        srs.DataLabels.Position = xlLabelPositionCenter
    Next srs

    ActiveChart.SetElement (msoElementLegendNone)

End Sub