> ## Documentation Index
> Fetch the complete documentation index at: https://support.taltech.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Collecting multiple consecutive fields of data into Excel

> Collect several values from one device reading into a single Excel row with WinWedge using its more advanced DDE mode.

This example demonstrates how to collect multiple successive data fields from WinWedge. While this example only shows 4 fields of data being requested, you can easily modify this example to collect up to 40 fields of data by simply changing the NumFields variable.

#### WinWedge DDE server settings

Remember to set WinWedge up in DDE Server Mode! See the [DDE Server Mode Setup Guide](https://support.taltech.com/winwedge/dde-server-mode-setup-guide.md).

DDE Application Name: **Excel**

DDE Topic: **System**

DDE Command: **\[RUN(“GetConsecutiveFields”)]**

#### Excel instructions

Create or edit a macro module in Excel and enter the following code in the module. If your device only has a single field of data, see the slimmed-down version in [Collecting a single field of data into Excel](https://support.taltech.com/winwedge/collecting-a-single-field-of-data-into-excel.md). (To create a new module click on **Insert > Module** from the Menus in the Visual Basic Editor Window.)

```
Sub GetConsecutiveFields()

    'Dimension all variables
    Dim R As Long, X As Long, Chan As Long, NumFields As Long, vDat As Variant, sDat As String

    ' Find the next empty row in Column A
    R = ThisWorkbook.Sheets(1).Cells(65000, 1).End(xlUp).Row + 1

    ' Establish DDE link to WinWedge on COM1
    Chan = DDEInitiate("WinWedge", "COM1")

    ' WinWedge can be configured to parse data into more than one data field.
    ' The following code demonstrates how to retrieve one or more data fields.
    ' Each field is placed in its own column followed by an optional date/time stamp.

    NumFields = 4 ' How many data fields are we retrieving from WinWedge?

    For X = 1 To NumFields                                      ' Loop through each field
        vDat = DDERequest(Chan, "Field(" & CStr(X) & ")")       ' Request data from WinWedge
        sDat = vDat(1)                                          ' Convert to a string
        ThisWorkbook.Sheets(1).Cells(R, X).Value = sDat  ' Place the data in a cell
    Next                                                        ' Continue Loop

    DDETerminate Chan ' Close the DDE channel

    ' IF YOU WOULD LIKE TO DO SOMETHING WITH THE DATA, YOUR CODE WOULD GO HERE

    ' You can also insert a date/time stamp after the last field by uncommenting the following line.
    ' ThisWorkbook.Sheets(1).Cells(R, NumFields + 1).Value = Now

End Sub
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.