View Single Post
  #7   Report Post  
Carolan
 
Posts: n/a
Default

Thanks so very much, Helmut - I even managed to change to column it effects.
It's a wonderful tool.
--
Carolan
Alberta, Canada


"Helmut Weber" wrote:

Hi Carolan,

May seem silly on my part - but how do I make this work work??


That's the real difficult part for a beginner,
hardly possible to take you by the hand with so many possibilities.

Just one of several ways:

Open the VBA-editor [alt F11],
open the project explorer [ctrl r],
which may be open anyway,
click on "normal" usually on top and bold
in the "project - project" window,
in the menu, click on "insert, module".

Paste this:
'---
Sub NextCell()
' revised !
Dim n As String
If Selection.Information(wdEndOfRangeColumnNumber) = 1 Then
n = Selection.Cells(1).Range.Text
n = Left(n, Len(n) - 2)
If IsNumeric(n) And _
Right(n, 2) " $" Then
n = n & " $"
Selection.Cells(1).Range.Text = n
End If
End If
WordBasic.NextCell
End Sub
'---

Save: [ctrl s]
Close: [alt F4]

If You press [tab] in a cell,
the built in command "NextCell" is executed.
However, since you have your own command "NextCell" now,
your "NextCell" is executed.
It overrides the built in command.

But, as with the new "NextCell"
the selection wouldn't move anymore,
it is necessary to have a substitute,
which is WordBasic.NextCell, a usefule relict from former times.

The macro grabs the text in the cell,
cuts off the cell mark, which is two characters long,
checks whether what's left is a number,
checks whether the rightmost 2 characters are not " $" anyway,
and if so, set the cells text to the number & " $".


HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"