下面的代碼工作的Excel列:如何使用列數來引用,而不是列字母
Imports Microsoft.Office.Interop
Dim xlApp As New Excel.Application
xlApp.Visible = True
Dim wb1 As Excel.Workbook
wb1 = xlApp.Workbooks.Open("C:\Book1.xlsx")
Dim ws1 As Excel.Worksheet
ws1 = CType(wb1.Sheets(1), Excel.Worksheet)
With ws1
CType(.Columns("K:XFD"), Excel.Range).NumberFormat = "General"
End With
我想使用的列號而不是列字母。
這是我試過,但它不工作:
With ws1
CType((.Columns(11), .Columns(.Columns.Count)), Excel.Range)).NumberFormat = "General"
End With
任何錯誤?預期與實際產出? –