VBA求助,要求对象
各位高手:帮忙看看下面程序的问题!多谢了Sub打开excel表格()DimmyPath$,myFile$,AKAsWorkbook,OAKAsWorkbookDimLot...
各位高手:帮忙看看下面程序的问题!多谢了
Sub 打开excel表格()
Dim myPath$, myFile$, AK As Workbook, OAK As Workbook
Dim LotID As String, GlassID As String
Set OAK = ActiveWorkbook
Application.ScreenUpdating = False '冻结屏幕,以防屏幕抖动
myPath = "C:\Documents and Settings\Administrator\桌面\Top secret\Raw Data\" '把文件路径定义给变量
myFile = Dir(myPath & "*.csv") '依次找寻指定路径中的*.csv文件
I = 1
Do While myFile <> "" '当指定路径中有文件时进行循环
If myFile <> ThisWorkbook.Name Then
Set AK = Workbooks.Open(myPath & myFile) '打开符合要求的文件
Set LotID = Right(AK.Sheets(1).[A1].Value, 10)
Set GlassID = Right(AK.Sheets(1).[A2].Value, 1)
If Right(AK.Sheets(1).[A3].Value, 4) = 1410 Or 4410 Then
If Right(AK.Sheets(1).[A3].Value, 4) = 1410 Then
AK.ActiveSheet.Range("E20:E55").Copy OAK.Sheets(1).Cells(4, I + 1)
OAK.Sheets(1).Cells(1, 3 * I - 1) = LotID
OAK.Sheets(1).Cells(3, I + 1) = GlassID
Else
AK.ActiveSheet.Range("E20:E43").Copy OAK.Sheets(2).Cells(4, I + 1)
OAK.Sheets(2).Cells(1, 3 * I - 1) = LotID
OAK.Sheets(2).Cells(3, I + 1) = GlassID
End If
End If
AK.Close False
End If
I = I + 1
myFile = Dir '找寻下一个*.csv文件
Loop
Application.ScreenUpdating = True '冻结屏幕,此类语句一般成对使用
End Sub 展开
Sub 打开excel表格()
Dim myPath$, myFile$, AK As Workbook, OAK As Workbook
Dim LotID As String, GlassID As String
Set OAK = ActiveWorkbook
Application.ScreenUpdating = False '冻结屏幕,以防屏幕抖动
myPath = "C:\Documents and Settings\Administrator\桌面\Top secret\Raw Data\" '把文件路径定义给变量
myFile = Dir(myPath & "*.csv") '依次找寻指定路径中的*.csv文件
I = 1
Do While myFile <> "" '当指定路径中有文件时进行循环
If myFile <> ThisWorkbook.Name Then
Set AK = Workbooks.Open(myPath & myFile) '打开符合要求的文件
Set LotID = Right(AK.Sheets(1).[A1].Value, 10)
Set GlassID = Right(AK.Sheets(1).[A2].Value, 1)
If Right(AK.Sheets(1).[A3].Value, 4) = 1410 Or 4410 Then
If Right(AK.Sheets(1).[A3].Value, 4) = 1410 Then
AK.ActiveSheet.Range("E20:E55").Copy OAK.Sheets(1).Cells(4, I + 1)
OAK.Sheets(1).Cells(1, 3 * I - 1) = LotID
OAK.Sheets(1).Cells(3, I + 1) = GlassID
Else
AK.ActiveSheet.Range("E20:E43").Copy OAK.Sheets(2).Cells(4, I + 1)
OAK.Sheets(2).Cells(1, 3 * I - 1) = LotID
OAK.Sheets(2).Cells(3, I + 1) = GlassID
End If
End If
AK.Close False
End If
I = I + 1
myFile = Dir '找寻下一个*.csv文件
Loop
Application.ScreenUpdating = True '冻结屏幕,此类语句一般成对使用
End Sub 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询