View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 293
Default Fill a word form clicking on an excel cell

Hi Denis,

You could use a SelectionChange event-driven macro attached to the relevant worksheet. The following example populates an array with
the contents of columns A:D for the current row if any of the cells in A1:A10 is selected. It then outputs those values via a
message box.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i As Integer
Dim MyStr(3)
If Intersect(Target, ActiveSheet.Range("A1:A10")) Is Nothing Then Exit Sub
For i = 0 To 3
MyStr(i) = Target.Cells(1, i + 1).Value
Next
MsgBox Join(MyStr(), vbCrLf)
End Sub

--
Cheers
macropod
[MVP - Microsoft Word]


"Denis" wrote in message ...
Hi all,
I would like to be able to fill a word form from an excel sheet by clicking
on a cell and transferring the data from the different cells of the row in a
word document.
example :
Excel sheet :
Name1 address1 code1 city1
Name2 address2 code2 city2

I click on the cell Name1 and may be active a macro or a specific button to
get my word document filled with the information.

I know how to insert cells into a word document, but I would like to have an
automation when I click on a row or on a cell.
I'm not aware about programming so it could be great if the solution was
very easy to set up.
Thanks a lot