EXCELの列複数削除
VB6.0で開発しています。
下のようにEXCELの列を複数削除していますが
思うように削除されません。
削除はされるのですが
B列を削除してから次C列を削除となってしまっているので
C列を削除する時は元々のC列ではなく
B列を削除してからのC列を削除してしまいます。
どう直せばいいのでしょうか?
お願いします。
Private Sub Command2_Click()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim B As Integer
Dim C As Integer
Dim D1 As Integer
Dim E As Integer
Dim G As Integer
Dim H As Integer
Dim K As Integer
Dim L As Integer
Dim M As Integer
Dim N As Integer
Dim P As Integer
Dim R As Integer
Dim T As Integer
Dim U As Integer
Dim V As Integer
Dim Y As Integer
Dim Z As Integer
Dim AA As Integer
Dim AB As Integer
Dim AC As Integer
Dim AD As Integer
Dim AE As Integer
Dim AF As Integer
Dim AG As Integer
Dim AH As Integer
Dim AI As Integer
Dim AJ As Integer
Dim AL As Integer
Dim AM As Integer
Dim AP As Integer
Dim AQ As Integer
Dim AR As Integer
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\Users\maki\Documents\Book1")
Set xlSheet = xlBook.Worksheets("Sheet1")
xlApp.Visible = True
B = 2
C = 3
D1 = 4
E = 5
G = 7
H = 8
K = 11
L = 12
M = 13
N = 14
P = 16
R = 18
T = 20
U = 21
V = 22
Y = 25
Z = 26
AA = 27
AB = 28
AC = 29
AD = 30
AE = 31
AF = 32
AG = 33
AH = 34
AI = 35
AJ = 36
AL = 38
AM = 39
AP = 42
xlSheet.Cells(1, C).EntireColumn.Delete
xlSheet.Cells(1, D1).EntireColumn.Delete
xlSheet.Cells(1, E).EntireColumn.Delete
xlSheet.Cells(1, G).EntireColumn.Delete
xlSheet.Cells(1, H).EntireColumn.Delete
xlSheet.Cells(1, K).EntireColumn.Delete
xlSheet.Cells(1, M).EntireColumn.Delete
xlSheet.Cells(1, N).EntireColumn.Delete
xlSheet.Cells(1, P).EntireColumn.Delete
xlSheet.Cells(1, R).EntireColumn.Delete
xlSheet.Cells(1, T).EntireColumn.Delete
xlSheet.Cells(1, U).EntireColumn.Delete
xlSheet.Cells(1, V).EntireColumn.Delete
xlSheet.Cells(1, Y).EntireColumn.Delete
xlSheet.Cells(1, Z).EntireColumn.Delete
xlSheet.Cells(1, AA).EntireColumn.Delete
xlSheet.Cells(1, AB).EntireColumn.Delete
xlSheet.Cells(1, AC).EntireColumn.Delete
xlSheet.Cells(1, AD).EntireColumn.Delete
xlSheet.Cells(1, AE).EntireColumn.Delete
xlSheet.Cells(1, AF).EntireColumn.Delete
xlSheet.Cells(1, AG).EntireColumn.Delete
xlSheet.Cells(1, AH).EntireColumn.Delete
xlSheet.Cells(1, AI).EntireColumn.Delete
xlSheet.Cells(1, AJ).EntireColumn.Delete
xlSheet.Cells(1, AL).EntireColumn.Delete
xlSheet.Cells(1, AM).EntireColumn.Delete
xlSheet.Cells(1, AP).EntireColumn.Delete
Set xlApp = Nothing
Set xlBook = Nothing
Set xlSheet = Nothing
End Sub
お礼
回答頂きありがとうございました。