Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21281

Need help to change macro code into VB6 exe program

$
0
0
Dear all,

I have an excel macro to copy cell value if meet certain criteria. Now i'm trying to change the macro code to be a VB6 code so that i can create an .exe program. But i'm not sure how to to that because in macro i used the term Cell, Sheet, Range and so on. I want to change my macro into an .exe program because .exe program can be run anywhere, however the macro need to be run on workstation installed with Microsoft Excel only.

Basically I have 2 files; FileA and FileB. If the value in Column D in FileA is COUNTRY then the program should get the value in Column B. But i just i want to get the 12 character on the right e.i. ABCDEF1234567898 then it will be EF1234567898. The the program will search this value in FileB. If match found then it will copy the value in
Column H e.i. JAPAN and paste it in Column E in FileA. Below are my macro code.


Sub MapCountry()
For Each cell In Sheets("Sheet1").Range("D1:D" & Range("B" & Rows.Count).End(xlUp).Row)
If UCase(cell.Value) = "COUNTRY" Then
FindString = Right(Cells(cell.Row, cell.Column - 2), 12)
If Trim(FindString) <> "" Then
With Sheets("Sheet3").Range("D:D")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Sheets("Sheet1").Range(cell.Address).Offset(0, 1).Value = Sheets("Sheet2").Range(Rng.Address).Offset(0, 4).Value
Else
MsgBox "No match found for string " & FindString
End If
End With
End If
End If
Next

End Sub

Viewing all articles
Browse latest Browse all 21281

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>