0
I am trying to set a range in Vb.net to write data in the blue marked fields:
I tried to use this code I found on the Microsoft help pages but I think it is intended for VBA only:
Sub ClearRanges()
Worksheets("Sheet1").Range("C5:D9,G9:H16,B14:D18").ClearContents
End Sub
My current code is this:
Dim appXL As Excel.Application
Dim wbXL As Excel.Workbook
Dim shXL As Excel.Worksheet
Dim raXL As Excel.Range
Try
' Open workbook.
wbXL = appXL.Workbooks.Open(My.Application.Info.DirectoryPath & "\test.xltx")
shXL = wbXL.ActiveSheet
' Define Range.
shXL.Range("A2:E2,A5:E5,A8:E8,A11:E11,A14:E14,A17:E17,A20:E20,A23:E23,A26:E26,A29:E29,A32:E32,A35:E35,A38:E38").Value = "TEST"
Catch ex As Exception
MessageBox.Show("Error : " + ex.Message)
appXL.Quit()
End Try
Please translate your question.
– Daniel Mendes
I’m sorry, I already have this.
– RealK
The content is not written in the spreadsheet?
– CypherPotato