|
本帖最后由 kingboy2000 于 2018-12-14 19:27 编辑
各位大神
小弟有个棘手的问题,有一行语句总是过不去,请帮忙看看,下周就要解决时间紧迫,多谢各位了!!!
在Repair report of Oct 这个表里根据Value和week和year 位置的值,去填写F Temp 表里相应的位置,如同一个week, value 值为0 则数据不发生变化,如value值为1,则在此位置+1
Sub Macro1()
'
' Macro1 Macro
' Make a project with this file
' definition below:
Dim i_row, j_year, k_week, m_value, Row_location, Column_location As Integer
Dim i_1, j_1, k_1, i_2, j_2, k_2, i_start, i_end As Integer
Dim word_1, word_2, word_3 As String
'
'Start of the program
i_row = 1
loop_1:
Loop_start:
i_row = i_row + 1
Sheets("Repair report of Oct").Select
m_value = Value.cell(i_row, 8)----------------------------->总是报错
If m_value = 0 Then GoTo Loop_start 'duplicated rows.
word_1 = Value.cell(i, 5)
j_year = Value.cell(i, 6)
k_week = Value.cell(i, 7)
If word_1 = "" Then GoTo end_loop_1 'end of the database
Sheets("F Temp").Select
k_1 = (j_year - 2015) * 2
'Find the row location
i_start = Value.cell(2, k_1)
i_end = Value.cell(2, k_1 + 1)
i_2 = i_start
Loop_find_row_number:
Sheets("F Temp").Select
If Value.cell(i_2, 1) = word_1 Then GoTo End_Loop_find_row_number
i_2 = i_2 + 1
GoTo Loop_find_row_number
End_Loop_find_row_number:
Row_location = i_2 'Row nubmer found
'Find the column location
i_2 = i_start
Loop_find_column_number:
Sheets("F Temp").Select
If Value.cell(6, i_2) = k_week Then GoTo End_find_column_number
i_2 = i_2 + 1
If i_2 > i_end Then GoTo End_find_column_number
GoTo Loop_find_column_number
End_find_column_number:
Column_location = i_2
'now modify the F_temp
Sheets("F Temp").Select
Value.cell(Row_location, Column_location) = Value.cell(Row_location, Column_location) + 1
end_loop_1:
End Sub
|
|