请VB区的朋友们帮我看看这段代码,我把问题用“//”注出来了。请解释一下。谢谢。
问题也在下边了,我用"//"注出来了。请帮我看看。帮我解释一下。谢谢。
----------------------
Private Sub CommandButton1_Click()
Call Spread_MAN //调用Spread_MAN函数
Worksheets("MAN Label").Range("A1:I525").Copy //我认为是COPY man label工作表的A1:I525
ActiveSheet.Range("A271").PasteSpecial _ //粘贴到当然工作SHEET的A271
SkipBlanks:=True //这句是什么意思?
End Sub
-----------------------
'anchor = "B240"
'anchor2 = "A252"
'products = 40
'table_spacing = 3
'layers = 11
Function Test(p_num) //定义了TEST函数 ()里的P_NUM是什么意思?
p_index = p_num
Call fills_first(p_index)
' B118 means start point
Range("B248").Select //这句不太明白,SELECT了B248什么?
ActiveCell.Offset(0, p_index - 1).Range("A1").Select //这句不太明白
For j = 1 To 11 //我想知道这个for完成了什么工作?
Range("B248").Select
ActiveCell.Offset(j, p_index - 1).Range("A1").Select
' ActiveCell.Offset(1, 0).Range("A1").Select
If ActiveCell.Value = 0 Then
aa = 1 //这里的aa是个什么东西?aa不定事先定义吗?
Else
n_value = ActiveCell.Value
Call fills(n_value, j)
End If
b_value = ActiveCell.Value
Next
loop_count = p_index
' fixed_change_rows means distance between the table
fixed_change_rows = 44
' tmp matrix start point
tmp_matrix_row = 272
tmp_matrix_col = 2
' capacity matrix start point
capacity_row = 184
capacity_col = 2
' consumption materix start point
consumption_row = 35
consumption_col = 2
d_factor = Cells(capacity_row + p_index - 1, capacity_col + p_index - 1).Value
'Change 11 to whatever number to change column size
For j_1 = 1 To 11 //我想知道这个for完成了什么工作
'B283 = tmp_matrix start point
Cells(tmp_matrix_row, tmp_matrix_col).Select //这是SELECT了什么?
' Range("B283").Select
' ActiveCell.Offset(fixed_change_rows * loop_count, j_1 - 1).Range("A1").Select
ActiveCell.Offset(fixed_change_rows * loop_count, p_index - 1).Range("A1").Select
'Change 40 to whatever number to change row size
For i_1 = 1 To 40
' temp_value = ActiveCell.Offset(-1 * fix_change_rows * loop_count, 0).Range("A1").Value
temp_value = Cells(tmp_matrix_row + i_1 - 1, tmp_matrix_col + j_1 - 1).Value * Cells(capacity_row + loop_count - 1, capacity_col + j_1 - 1).Value * Cells(consumption_row + i_1 - 1, consumption_col + loop_count - 1).Value
If (temp_value) <> 0 Then //这个for完成了什么工作
' Cells(tmp_matrix_row + fix_change_rows * loop_count, tmp_matrix_col + fix_change_rows * loop_count).Value = temp_value
ActiveCell.Value = temp_value
End If
ActiveCell.Offset(1, 0).Range("A1").Select
Next
Next
For i_2 = 1 To p_index - 1
m_factor = Cells(capacity_row + p_index - 1, capacity_col + i_2 - 1).Value
Cells(tmp_matrix_row, tmp_matrix_col).Select
ActiveCell.Offset(fixed_change_rows * loop_count, i_2 - 1).Range("A1").Select
For i_3 = 1 To 40
If m_factor <> 0 Then
temp_value_1 = (Cells(tmp_matrix_row + (fixed_change_rows * loop_count) + i_3 - 1, tmp_matrix_col + p_index - 1).Value / d_factor) * m_factor //这里是不是进行了一个VALUE的计算?
If (temp_value_1) <> 0 Then
ActiveCell.Value = temp_value_1
End If
End If
ActiveCell.Offset(1, 0).Range("A1").Select
Next
Next
End Function
Function do_it(j_value, xx)
Range("B248").Select
ActiveCell.Offset(0, xx - 1).Range("A1").Select
For k = 1 To 11
ActiveCell.Offset(1, 0).Range("A1").Select
If ActiveCell.Value = 0 Then
aa = 1
Else
n_value = ActiveCell.Value * j_value
row_number = ActiveCell.Row
col_number = ActiveCell.Column
Call fills(n_value, k)
Range("A1").Select
ActiveCell.Offset(row_number - 1, col_number - 1).Range("A1").Select
End If
Next
End Function
Function fills(p_value, p_x)
pp_x = p_x
b_value = p_value
'Arrow table start point
major_row = 208
major_col = 2
Range("A272").Select
ActiveCell.Offset(0, pp_x).Range("A1").Select
For i = 1 To 40
' a_value = ActiveCell.Offset(0, -18).Range("A1").Value
a_value = Cells(major_row + i - 1, major_col + pp_x - 1).Value
If (a_value * b_value) <> 0 Then
ActiveCell.Value = a_value * b_value
End If
ActiveCell.Offset(1, 0).Range("A1").Select
Next
Call do_it(b_value, p_x)
End Function
Function fills_first(p_y)
pp_y = p_y
' Range("A252").Select
' ActiveCell.Offset(0, pp_y).Range("A1").Select
major_row = 208
major_col = 2
For n_1 = 1 To pp_y
Range("A272").Select
ActiveCell.Offset(0, n_1).Range("A1").Select
For i = 1 To 40
c_value = Cells(major_row + i - 1, major_col + n_1 - 1).Value
If (c_value) <> 0 Then
ActiveCell.Value = c_value
End If
ActiveCell.Offset(1, 0).Range("A1").Select
Next
Next
End Function
Sub Spread_MAN()
For loop_1 = 1 To 11 //这里的loop是什么?
Call Test(loop_1) //Test(loop_1) 是做什么用的?
Next
'Call Test(1)
End Sub