I have looked around and found this as the best place to ask the question. I have an excel spreadsheet that is getting information from a control Logix. The values that are coming in need to be divided by 10 so they display on the spreadsheet properly. Example, the temp in the PLC register is 1045, it is displayed on the HMI as 104.5
When I import the value into excel it is 1045
Is there a way in my VB code to do the division then place it in the cell? I realize I could add a bunch of code in the PLC to do the math but was hoping for this solution instead.
Here is my code. I need to divide the values that will be displayed in the spreadsheet for cells 4,11 : 4:16
Private Sub Workbook_Open()
'Data collection for L01PL2
'This excel file opens from Windows Task Manager every 15 minutes
'and runs this macro for data collection
'then saves the file with the name "Melts Data Collection"
'then closes the file automatically
'Written By: Steve Hannahs 01/10/2017
CurrentTime = Format(Now(), "mm/dd/yyyy - hh:mm")
Cells(4, 1).Select
ActiveCell.EntireRow.Insert
Cells(4, 1).Value = CurrentTime
RSIChan = DDEInitiate("RSLinx", "L01PL2")
Cells(4, 2).Value = DDERequest(RSIChan, "TotePress.PressServoPosition")
Cells(4, 3).Value = DDERequest(RSIChan, "TotePress.VFDMedSpeedSetpoint")
Cells(4, 4).Value = DDERequest(RSIChan, "TP2.ON")
Cells(4, 5).Value = DDERequest(RSIChan, "Pump6_Output_Display")
Cells(4, 6).Value = DDERequest(RSIChan, "BufferTamkTemp")
Cells(4, 7).Value = DDERequest(RSIChan, "BT1.LVL_MV")
Cells(4, 8).Value = DDERequest(RSIChan, "MMI.P1_LMP")
Cells(4, 9).Value = DDERequest(RSIChan, "CURRENT.P1_SPD_SP")
Cells(4, 10).Value = DDERequest(RSIChan, "MMI.P1_CAP_MV")
Cells(4, 11).Value = DDERequest(RSIChan, "P1.CONT_VAL")
Cells(4, 12).Value = DDERequest(RSIChan, "MMI.MH_TMPIN_MV")
Cells(4, 13).Value = DDERequest(RSIChan, "Rm105RH.Value")
Cells(4, 14).Value = DDERequest(RSIChan, "MAU1N7[1]")
Cells(4, 15).Value = DDERequest(RSIChan, "MAU1N7[2]")
Cells(4, 16).Value = DDERequest(RSIChan, "MAU1N7[3]")
Cells(4, 17).Value = DDERequest(RSIChan, "HX3.OutletTT[1].Value")
Cells(4, 18).Value = DDERequest(RSIChan, "HX3.InletTT[1].Value")
Cells(4, 19).Value = DDERequest(RSIChan, "T1.Mode[1].0")
Cells(4, 20).Value = DDERequest(RSIChan, "T1.Mode[1].1")
Cells(4, 21).Value = DDERequest(RSIChan, "T1.Mode[1].2")
Cells(4, 22).Value = DDERequest(RSIChan, "T1.Mode[1].3")
Cells(4, 23).Value = DDERequest(RSIChan, "T1.Mode[1].4")
Cells(4, 24).Value = DDERequest(RSIChan, "LSC3.Pressure")
DDETerminate (RSIChan)
Application.DisplayAlerts = False
Sheets("Coll").Copy
ActiveWorkbook.SaveAs Filename:="F:\Puree Melts\Melts Data Collection", FileFormat:=51
ActiveWorkbook.Close
ActiveWorkbook.Save
Application.Quit
End Sub