vb.netでExcelの1行をコピーしたい
WindowsXP(SP2) VB2005 Excel2007で開発を行っております。
Excelの操作について質問したいことがあり、投稿しました。
Excelシートの横一列をセル単位に罫線で囲み、その行を必要な行数分どんどん下にコピーしたいのですが、コピーの部分で行き詰ってしまいました。
以下がコードです。
' Excel用Objectの宣言
Public Shared xl As Excel.Application
Public Shared xlBooks As Excel.Workbooks
Public Shared xlBook As Excel.Workbook
Public Shared xlSheets As Excel.Sheets
Public Shared xlSheet As Excel.Worksheet
Public Shared xlBorders As Excel.Borders
Public Shared xlCells As Excel.Range
' ユーザID
x = 1
y = 1
' 罫線で囲む
xlBorders = xlSheet.Range(xlSheet.Cells(y, x), xlSheet.Cells(y, x)).Borders
xlBorders.LineStyle = Excel.XlLineStyle.xlContinuous
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBorders)
xlBorders = Nothing
' 住所
x = 2
y = 1
' 罫線で囲む
xlBorders = xlSheet.Range(xlSheet.Cells(y, x), xlSheet.Cells(y, x)).Borders
xlBorders.LineStyle = Excel.XlLineStyle.xlContinuous
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBorders)
xlBorders = Nothing
' 氏名
x = 3
y = 1
' 罫線で囲む
xlBorders = xlSheet.Range(xlSheet.Cells(y, x), xlSheet.Cells(y, x)).Borders
xlBorders.LineStyle = Excel.XlLineStyle.xlContinuous
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBorders)
xlBorders = Nothing
' Tel
x = 4
y = 1
' 罫線で囲む
xlBorders = xlSheet.Range(xlSheet.Cells(y, x), xlSheet.Cells(y, x)).Borders
xlBorders.LineStyle = Excel.XlLineStyle.xlContinuous
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBorders)
xlBorders = Nothing
' 備考
x = 5
y = 1
' 罫線で囲む
xlBorders = xlSheet.Range(xlSheet.Cells(y, x), xlSheet.Cells(y, x)).Borders
xlBorders.LineStyle = Excel.XlLineStyle.xlContinuous
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBorders)
xlBorders = Nothing
Dim i As Int16
For i = 0 To 15
' ここでコピーの処理を行う
Next
以上がコードとなります。
どなたかご教授をよろしくお願いします。
補足
おっしゃる意味は理解できますが問題を把握した上で書き込みをしたいのですが 何か方法はありますか