Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Shauna Kelly wrote me a wonderful script but unfortunaltey she wrote it
in Word and i need it in Excel. can anyone help me convert this script from Word to Excel? Below is the script: Option Explicit Sub AddTextToCells() Dim sStart As String Dim sCopy As String Dim sEnd As String Dim oTable As Word.Table Dim oRow As Word.Row Dim rngCell As Word.Range Dim rngCopy As Word.Range Dim bReplace As Boolean sStart = InputBox(Prompt:="Text to search for", _ Default:="STANDARDS FOR FOREIGN LANGUAGE LEARNING") sEnd = InputBox(Prompt:="Text to end with", _ Default:="CORE INSTRUCTION") Set oTable = ActiveDocument.Tables(1) For Each oRow In oTable.Rows 'Get the range of the cell Set rngCell = oRow.Cells(1).Range 'Omit the end of cell marker rngCell.End = rngCell.End - 1 'Process the cell If rngCell.Text = sStart Then bReplace = True 'Get the replacement text Set rngCopy = oRow.Next.Cells(1).Range rngCopy.End = rngCopy.End - 1 sCopy = rngCopy.Text 'Delete the row following our row oRow.Next.Delete ElseIf rngCell.Text = sEnd Then bReplace = False ElseIf bReplace Then rngCell.InsertBefore sCopy & " - " End If Next oRow End Sub Thanks in advance God bles jsd219 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel Macro call Word Macro with Parameters | Excel Programming | |||
Need syntax for RUNning a Word macro with an argument, called from an Excel macro | Excel Programming | |||
WORD-DELIMITED string vba macro for excel/word | Excel Programming | |||
passing arguments from an excel macro to a word macro | Excel Discussion (Misc queries) | |||
Macro - Open Word with Excel macro | Excel Discussion (Misc queries) |