Hi there,
I have used C++ and Java but never used VBA before so maybe my question is a bit naive.
This is how my data looks like:
A B B 1 36
B C FALSE 2 6
First two columns are names, third column is the comparison between Column 1 and Column 2, 4th and 5th columns are the values of 1st and 2nd column respectively.
I want to write a code such that
1) If column 3 is not false (for example B).
2) Then store the value of respective row of column 5 (e.g. 36)
3) Search "B" in column A.
4) Store the value of column 4 (e.g 2)
5) Subtract both values of column of 5 and column 4.
6) Write this new value in a new column. (34)
So far my code looks like:
Sub Comparison()
Dim Counter As Integer
Dim F1 As Integer
Dim C1 As String
For Counter = 1 To 2
If (Worksheets("Sheet2").Cells(Counter, 3).Value <> False) Then
C1 = Worksheets("Sheet2").Cells(Counter, 3).Value
F1 = Worksheets("Sheet2").Cells(Counter, 5).Value
End If
Next Counter
End Sub
I got stuck to search a value in a specific range and to have the related value of column 4 in a variable.
Thank you for your support!
I have used C++ and Java but never used VBA before so maybe my question is a bit naive.
This is how my data looks like:
A B B 1 36
B C FALSE 2 6
First two columns are names, third column is the comparison between Column 1 and Column 2, 4th and 5th columns are the values of 1st and 2nd column respectively.
I want to write a code such that
1) If column 3 is not false (for example B).
2) Then store the value of respective row of column 5 (e.g. 36)
3) Search "B" in column A.
4) Store the value of column 4 (e.g 2)
5) Subtract both values of column of 5 and column 4.
6) Write this new value in a new column. (34)
So far my code looks like:
Sub Comparison()
Dim Counter As Integer
Dim F1 As Integer
Dim C1 As String
For Counter = 1 To 2
If (Worksheets("Sheet2").Cells(Counter, 3).Value <> False) Then
C1 = Worksheets("Sheet2").Cells(Counter, 3).Value
F1 = Worksheets("Sheet2").Cells(Counter, 5).Value
End If
Next Counter
End Sub
I got stuck to search a value in a specific range and to have the related value of column 4 in a variable.
Thank you for your support!
Last edited: