我正在制作一张具有很多信息的Excel工作表来支持一个项目。这是该产品所有选项的列表。
正在努力从SiDAQ_Template Sheetet中将某些范围的数据转换成SiDAQ中的特定单元格。范围可以从1行到51行,并且这些行也应该动态插入和移除(就像您根据SiDAQ工作表中的选择上下滚动的窗帘一样)
我试图写下一些东西,但对我来说没有意义。
Sub test()
defining the worksheets used for the copy/paste of templates.
Dim ws1 As Worksheet: Set ws1 = ActiveWorkbook.Sheets("SiDAQ")
Dim ws2 As Worksheet: Set ws2 = ActiveWorkbook.Sheets("SiDAQ_Template")
defining the ranges of the templates, easier naming in the code
With ws2
Dim rng1 As Range: Set rng1 = Range("E2:F2") 'Speed
Dim rng2 As Range: Set rng2 = Range("E4:F4") 'Count
Dim rng3 As Range: Set rng3 = Range("E8:F8") 'EL2202 (1 ms)
Dim rng4 As Range: Set rng4 = Range("E9:F9") 'EL2202 (1 sec)
Dim rng5 As Range: Set rng5 = Range("E10:F10") 'EL2202 (1 hour)
Dim rng6 As Range: Set rng6 = Range("E11:F11") 'PPS
Dim rng7 As Range: Set rng7 = Range("E13:F13") 'I 4…20mA
Dim rng8 As Range: Set rng8 = Range("E16:F16") 'I 0...20mA
Dim rng9 As Range: Set rng9 = Range("E18:F18") 'V ±30V
Dim rng10 As Range: Set rng10 = Range("E19:F19") 'V ±10V
Dim rng11 As Range: Set rng11 = Range("E21:F21") 'V ±5V
Dim rng12 As Range: Set rng12 = Range("E23:F23") 'V ±2.5V
Dim rng13 As Range: Set rng13 = Range("E24:F24") 'V ±1.25V
Dim rng14 As Range: Set rng14 = Range("E25:F25") 'V ±640mV
Dim rng15 As Range: Set rng15 = Range("E26:F26") 'V ±320mV
Dim rng16 As Range: Set rng16 = Range("E27:F27") 'V ±160mV
Dim rng17 As Range: Set rng17 = Range("E28:F28") 'V ±80mV
Dim rng18 As Range: Set rng18 = Range("E29:F29") 'V ±40mV
Dim rng19 As Range: Set rng19 = Range("E30:F30") 'I ±20mA
Dim rng20 As Range: Set rng20 = Range("E31:F31") 'R 2W Ohm
Dim rng21 As Range: Set rng21 = Range("E32:F32") 'R 3W Ohm
Dim rng22 As Range: Set rng22 = Range("E33:F33") 'R 4W Ohm
Dim rng23 As Range: Set rng23 = Range("E34:F34") 'RTD 3W °C
Dim rng24 As Range: Set rng24 = Range("E36:F36") 'RTD 4W °C
Dim rng25 As Range: Set rng25 = Range("E37:F37") 'SG 1/4 3W 350Ohm mV/V
Dim rng26 As Range: Set rng26 = Range("E38:F38") 'SG 1/4 3W 120Ohm mV/V
Dim rng27 As Range: Set rng27 = Range("E39:F39") 'SG 1/2 3W mV/V
Dim rng28 As Range: Set rng28 = Range("E40:F40") 'SG 1/2 5W mV/V
Dim rng29 As Range: Set rng29 = Range("E41:F41") 'SG 1/1 4W mV/V
Dim rng30 As Range: Set rng30 = Range("E42:F42") 'SG 1/1 6W mV/V
Dim rng31 As Range: Set rng31 = Range("E43:F43") 'IEPE
Dim rng32 As Range: Set rng32 = Range("E44:F44") 'Thermocouples
Dim rng33 As Range: Set rng33 = Range("E46:F54") 'Power
Dim rng34 As Range: Set rng34 = Range("E55:F78") 'Corrosion
Dim rng35 As Range: Set rng35 = Range("E103:F104") 'ComNav
Dim rng36 As Range: Set rng36 = Range("E107:F129") 'RisoDau
Dim rng37 As Range: Set rng37 = Range("E153:F160") 'GPS
Dim rng38 As Range: Set rng38 = Range("E169:F178") 'RotorAzimut
Dim rng39 As Range: Set rng39 = Range("E189:F239") 'Camilla Bauer
Dim rng40 As Range: Set rng40 = Range("E291:F298") 'PTP
End With
Application.ScreenUpdating = False 'for quicker operation
For Each Cells In Column(5)
If Cells(Column, 5) = "EL*" Then
Next
Application.ScreenUpdating = True
End Sub
不同的范围取决于第5(E)列中是否有“ EL物质” 在SiDAQ工作表中,如果在SiDAQ工作表中第15(O)列中的单词rngXX也匹配
然后将范围插入与第5列和第15列的EL在同一行的第37列(AK)并向下插入,同时插入与粘贴到AK(37)列中的范围的行匹配的空白行