duncan4000
New Member
- Joined
- Nov 4, 2011
- Messages
- 4
im trying to write a program that reads the values in 2 columns and sums them together and puts the results in the 1st column but i cant get it to work
this is what i have so far. thanks for any help
Sub sumvalues()
Dim Column1, Column2
Dim StartRow, EndRow
Dim TempVal As Integer
Dim TempVal2 As Integer
Dim Ans As Integer
Dim RowNdx
Column1 = InputBox( _
prompt:="Input 1st column Letter")
Column2 = InputBox( _
prompt:="Input 2st column letter")
StartRow = InputBox( _
prompt:="Input start row number")
EndRow = InputBox( _
prompt:="Input end row number")
RowNdx = StartRow
Do
TempVal1 = Cells(RowNdx, "Column1").Value
TempVal2 = Cells(RowNdx, "Column2").Value
Ans = TempVal1 + TempVal2
Cells(RowNdx, "Column2").ClearContents
Cells(RowNdx, "Column1").ClearContents
Cells(RowNdx, "Column1").Value = Ans
RowNdx = RowNdx + 1
Loop Until (EndRow + 1)
End Sub
this is what i have so far. thanks for any help
Sub sumvalues()
Dim Column1, Column2
Dim StartRow, EndRow
Dim TempVal As Integer
Dim TempVal2 As Integer
Dim Ans As Integer
Dim RowNdx
Column1 = InputBox( _
prompt:="Input 1st column Letter")
Column2 = InputBox( _
prompt:="Input 2st column letter")
StartRow = InputBox( _
prompt:="Input start row number")
EndRow = InputBox( _
prompt:="Input end row number")
RowNdx = StartRow
Do
TempVal1 = Cells(RowNdx, "Column1").Value
TempVal2 = Cells(RowNdx, "Column2").Value
Ans = TempVal1 + TempVal2
Cells(RowNdx, "Column2").ClearContents
Cells(RowNdx, "Column1").ClearContents
Cells(RowNdx, "Column1").Value = Ans
RowNdx = RowNdx + 1
Loop Until (EndRow + 1)
End Sub