Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
364 views
in Technique[技术] by (71.8m points)

excel - How can I compare and match cells in different columns, then compare and match the matches to different columns?

I am currently looking to compare multiple Ranges in a specific order using VBA. The condition is to take Column A, compare it and identify matches within Column B. The specified adjacent cell to the left/right of the identified matches in column B, will then be considered column C, then compared and matched with column D. Finally the left/right adjacent cell to the identified matches in column D will be copied and pasted to a specified range in a separate sheet.

Snip01 https://1drv.ms/u/s!Ar3kJS7jPDiLgoh6QM6ZnFl_sjuZZQ

Snip02 https://1drv.ms/u/s!Ar3kJS7jPDiLgoh5zm1b2BozaT-0iw

Snip03 https://1drv.ms/u/s!Ar3kJS7jPDiLgoh4Ane8V1jZfoxbCA

Snip04 https://1drv.ms/u/s!Ar3kJS7jPDiLgoh3enh0OIUJ3m6BDA

Currently this is all I have written in VBA, and as you can probably tell, I am absolutely lost.

Sub MatchIt()

Dim Atlas As Range
Dim Atlas2 As Range

Dim Roster As Range
Dim Roster2 As Range

Dim Push As Range

Set Atlas = Range("D2")
Set Atlas2 = Range("M2")

Set Roster = Range("T2")
Set Roster2 = Range("S2")

Set Push = Range("AB2")

For Each cell In Push
    If Push.Value = Roster2.Value Then
        
    

End Sub

I am mostly getting stumped on how to specify a cell relative to a previous result (hopefully I'm wording this correctly). I would appreciate any help with this. Thank you.

question from:https://stackoverflow.com/questions/65876874/how-can-i-compare-and-match-cells-in-different-columns-then-compare-and-match-t

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...