visual_basic
Differences
This shows you the differences between two versions of the page.
visual_basic [2014/05/09 07:49] – created skipidar | visual_basic [2020/12/27 20:35] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== Visual Basic ===== | ||
+ | Visual Basic is the language of especially Microsoft Excel. | ||
+ | |||
+ | == Compare key columns A & C. Find where C=A. Copy value from column D to B == | ||
+ | |||
+ | <sxh vba> | ||
+ | Sub test() | ||
+ | |||
+ | Dim cpk1 As Integer, cpk2 As Integer, cvnew As Integer, cvold As Integer, i As Integer, j As Integer | ||
+ | |||
+ | With Worksheets(" | ||
+ | i = 2167 | ||
+ | cpk1 = 2 | ||
+ | cpk2 = 10 | ||
+ | cvnew = 6 | ||
+ | cvold = 11 | ||
+ | |||
+ | | ||
+ | For i = 1 To 3 ' | ||
+ | For j = 1 To 3 ' | ||
+ | | ||
+ | If .Cells(i, cpk1).Value = .Cells(j, cpk2).Value Then ' | ||
+ | MsgBox .Cells(i, cvnew).Value | ||
+ | ' MsgBox .Cells(j, cvold).Value | ||
+ | .Cells(i, cvnew).Value = .Cells(j, cvold).Value | ||
+ | Exit For ' break loop' | ||
+ | End If | ||
+ | Next j | ||
+ | Next i | ||
+ | |||
+ | End With | ||
+ | |||
+ | End Sub | ||
+ | |||
+ | </ |