snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Sub test6()
Dim wsData As New Worksheet
Dim i, j, k As Integer
Dim title1, title2 As Variant
Dim result As Variant
Set wsData = Sheets("Data")
i = 0
j = 3
k = 4
Do
title1 = wsData.Cells(j + i, 5)
title2 = wsData.Cells(k + i, 5)
result = wsData.Cells(j + i, 48)
If title1 = title2 Then
result = "1"
'Debug.Print "1"
Else
result = "0"
'Debug.Print "0"
End If
i = i + 1
Loop Until title1 = ""
End Sub
You do not have the required permissions to view the files attached to this post.
Dim wsData As New Worksheet
Dim i, j, k As Integer
Dim title1 As Range, title2 As Range
Dim result As Range
Set wsData = Sheets("Data")
i = 0
j = 3
k = 4
Do
Set title1 = wsData.Cells(j + i, 5)
Set title2 = wsData.Cells(k + i, 5)
Set result = wsData.Cells(j + i, 48)
If title1 = title2 Then
result = "1"
'Debug.Print "1"
Else
result = "0"
'Debug.Print "0"
End If
i = i + 1
Loop Until title2 = ""