excel - 从多个工作簿中提取数据
问题描述
我想使用通配符和结束名称(以蓝色突出显示)从多个工作簿中的选项卡名称(以黄色突出显示)下的列名(以绿色突出显示)下的红色框中提取数据。创建工作簿后,我的代码停止了。(下面的代码)并对其进行格式化。请帮助我如何获取所有数据,直到最后一个数据
Private Sub CommandButton3_Click()
Dim JCN As String, Path As String
UserForm1.Hide
JCN = TextBox3.Value
ReportName = JCN & " PANEL NESTING REPORT"
UserName = Environ$("Username")
Path = "C:\Users\" & UserName & "\Desktop\"
Workbooks.Add
ActiveSheet.Name = "NESTING REPORT"
'Column Header
Range("B1").Value = "WBS Code"
Range("C1").Value = "Airline Code"
Range("D1").Value = "JCN"
Range("E1").Value = "'3000LVL"
Range("F1").Value = "MBOM"
Range("G1").Value = "Make Part"
Range("H1").Value = "LAV"
Range("I1").Value = "LC Number"
Range("J1").Value = "Rev"
Range("K1").Value = "Size"
Range("L1").Value = "Part Number"
Range("M1").Value = "Rev"
Range("N1").Value = "Qty"
Range("O1").Value = "Classification"
Range("P1").Value = "Type"
Range("Q1").Value = "Thickness"
Range("R1").Value = "Rawmat"
Range("S1").Value = "Remarks"
Range("T1").Value = "'.400 Code"
Range("U1").Value = "W.O."
'Format Column Header
Range("B1:U1").Select
Selection.Font.Bold = True
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight2
.TintAndShade = -0.499984740745262
.PatternTintAndShade = 0
End With
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Columns("B:U").EntireColumn.AutoFit
ActiveWindow.DisplayGridlines = False
'Extract Data
'Save Workbook
ActiveWorkbook.SaveAs Filename:=Path & ReportName & ".xlsx"
'Close Workbook
ActiveWorkbook.Close
End Sub
解决方案
推荐阅读
- pandas - 计算数据框中列中的组
- typescript - Angular 应用程序的 IntelliJ javascript 调试器与特定配置文件上的 Chrome
- firebase - java.lang.IllegalArgumentException:服务未注册 Flutter 和 Firebase Google SignIn
- r - 使用 paste0() 重命名列时应该使用哪些运算符?
- javascript - 在 JavaScript 中将字符串转换为日期对象默认时间为 12:00
- java - 列表函数 add() 不起作用,但我不知道为什么?
- debugging - GDB共享选项卡下嵌入代码的目的是什么
- arduino - 使用 ESP32 计算电能表中的电能的问题
- go - 为什么通过 go 插件调用函数比直接调用函数更快
- amazon-web-services - 监控在 NewRelic 中执行的 lambda