Monday, January 21, 2013

Relink Sections

Sub RelinkSections()

Dim myRng As Word.Range
Set oDoc = ActiveDocument
For i = 1 To oDoc.Sections.Count

With oDoc.Sections(i)

For j = 1 To 3

.Headers(j).LinkToPrevious = True
.Footers(j).LinkToPrevious = True

Next j

End With

Next i

lbl_Exit:

Exit Sub

End Sub

Add Section & Kill Link 2 Previous

Option Explicit


Dim i As Long
Dim j As Long
Dim oDoc As Word.Document

Sub AddSectionAndKillLinkToPrevious()

Dim myRng As Word.Range
Set oDoc = ActiveDocument
Selection.InsertBreak Type:=wdSectionBreakNextPage

'Get the index number of the added section

i = oDoc.Range(0, Selection.Sections(1).Range.End).Sections.Count
With oDoc.Sections(i)
For j = 1 To 3
.Headers(j).LinkToPrevious = False
.Footers(j).LinkToPrevious = False
Next j
End With

'Note: j provides the constant value to unlink all three header\footer types.

lbl_Exit:

Exit Sub

End Sub

Friday, January 11, 2013

Joining Excel Column Text Together

Joining Excel Column Text Together:-
==============================

There are times where we import text file into Excel an we get text that are separated. I received an email asking how put these text together. Select across your cells first and run this VBA macro.

Sub JoinColumnTexts()

myCol = Selection.Columns.Count

For i = 1 To myCol

ActiveCell = ActiveCell.Offset(0, 0) & ActiveCell.Offset(0, i)

ActiveCell.Offset(0, i) = ""

Next i
End Sub

Send eMail though excel workbook

eMail Workbook:-

To email your current workbook the following code.

Sub Email()

ActiveWorkbook.SendMail recipients:=chithu.palaniappan@gmail.com

End Sub



Highlight duplicate data in your worksheet.

There are times you need to highlight duplicate data in your worksheet.

Sub DupsRecord()


Application.ScreenUpdating = False

Rng = Selection.Rows.Count

For i = Rng To 1 Step -1

myCheck = ActiveCell

ActiveCell.Offset(1, 0).Select

For j = 1 To i

If ActiveCell = myCheck Then

Selection.Font.Bold = True

Selection.Font.ColorIndex = 3

End If

ActiveCell.Offset(1, 0).Select

Next j

ActiveCell.Offset(-i, 0).Select

Next i

Application.ScreenUpdating = True

End Sub



VBA coding and template designing for 2013?

How to enable excel 2013 developer tab for VBA coding and template designing.


1. First ope the `backstage view' of excel 2013 by clicking the "file" option in the ribbon.
2. Click Options -> a Pop Up apprears.
3. Cick "Customize ribbon" Option.
4. In the right column choose the "Main Tabs" from the dropdown (by default it will be there).
5. please check the ‘Developer’ cehck box.
6. click OK -> close and reopen your excel.
you have successfully enabled the Developer tab and have access to all kind of developer tools in excel 2013 to begin your development.

Identify Browser Version using Excel VBA:-

Identify Browser Version using Excel VBA:-




Sub CheckWebOptions()

Dim wkbOne As Workbook
Set wkbOne = Application.Workbooks(1)

‘ Determine if IE8 is the target browser.


If wkbOne.WebOptions.TargetBrowser = msoTargetBrowserIE6 Then

MsgBox "The target browser is IE6 or later."

ElseIf wkbOne.WebOptions.TargetBrowser = msoTargetBrowserIE5 Then

MsgBox "The target browser is IE5 or later."

ElseIf wkbOne.WebOptions.TargetBrowser = msoTargetBrowserIE4 Then

MsgBox "The target browser is IE4 or later."

ElseIf wkbOne.WebOptions.TargetBrowser = msoTargetBrowserV4 Then

MsgBox "Microsoft Internet Explorer 4.0, Netscape Navigator 4.0, or later."

ElseIf wkbOne.WebOptions.TargetBrowser = msoTargetBrowserV3 Then

MsgBox "Microsoft Internet Explorer 3.0, Netscape Navigator 3.0, or later."

Else

MsgBox "The target browser is not in the given list"

End If


End Sub