Sub AddNumbersOnOneRow
Const s_Field_ColA = "ColumnA"
Const s_Field_ColB = "ColumnB"
Const s_Field_ColC = "ColumnC"
Const s_Field_ColD = "ColumnD"
Dim iPsDepth As Integer
Dim iPsColA As Integer
Dim iPsColB As Integer
Dim iPsColC As Integer
Dim iPsColD As Integer
Dim lRow As Long
Dim dDepth As Double
Dim ColumnD As Double
'------------------------
'Determine the field positions of the necessary fields in the array.
If InitFieldsFnB(gs_Depth, iPsDepth, _
s_Field_ColA, iPsColA, _
s_Field_ColB, iPsColB, _
s_Field_ColC, iPsColC) _
Then
'One or more of the required fields missing from the table.
Exit Sub
End If
With gINTRules.GridData
iPsDepth = .FieldCol("Depth")
iPsColA = .FieldCol("ColumnA")
iPsColB = .FieldCol("ColumnB")
iPsColC = .FieldCol("ColumnC")
iPsColD = .FieldCol("ColumnD")
For lRow = 1 To glNumRows
ColumnD= CDbl(gsDataA(iPsColA, lRow))+ CDbl(gsDataA(iPsColB, lRow))
gsDataA(iPsColD, lRow)= CStr(ColumnD)
Next lRow
End With
End Sub
이 매크로를 실행할 때 오류가 발생하지 않았습니다. 그러나이 매크로는 대답 D 열에 아무것도주지 않습니다.테이블 열에서 VBA 계산을 수행하지 못했습니다.
열 A에 추가 할 열 A 및 열 B ! [이것은 내 표입니다, 나는 열 A와 ColumnB를 columnD에 넣습니다. . 나는 매크로를 실행하면하지만
내가 다음 줄이 나에게 문제를주고있는 것으로 생각] 아무것도 얻을 :
For lRow = 1 To glNumRows
ColumnD= CDbl(gsDataA(iPsColA, lRow))+ CDbl(gsDataA(iPsColB, lRow))
gsDataA(iPsColD, lRow)= CStr(ColumnD)
Next lRow
은 어떤 도움이 크게 감사한다!
당신이 다른 곳에서 값을 설정하지 않는 한'#LibInclude "common procedures"
Option Explicit
Public Sub Main
Dim gsDataA As Variant
Dim glNumRows As Integer
With gINTRules.GridData
'Put the grid data into a working string data array.
gsDataA = .DataArray
glNumRows = UBound(gsDataA, 2)
'Put the modified data array back into the input grid.
.DataArray = gsDataA
'Success is True if there were no errors.
gINTRules.Success = CBool(.ErrorCol = 0)
End With
End Sub
메인에 glNumRows를 넣었지만 여전히 루프가 실행되지 않습니다 – user2634156
@ user2634156 업데이트 된 코드를 포함하도록 원래 게시물을 편집 할 수 있습니까? 비 형식화 된 주석 블록으로 머리 또는 꼬리를 만들 곰입니다. – sous2817
@ user2634156 수정 사항을 기반으로 답변을 업데이트했습니다. – sous2817