Copy column data matching the column name
Closed
spaceenigma
Posts
1
Registration date
Tuesday January 27, 2009
Status
Member
Last seen
January 27, 2009
-
Jan 27, 2009 at 10:32 PM
Helper - Feb 4, 2009 at 07:42 PM
Helper - Feb 4, 2009 at 07:42 PM
Related:
- Copy column data matching the column name
- Display two columns in data validation list but return only one - Guide
- Tmobile data check - Guide
- How do i auto number a column in excel? ✓ - Excel Forum
- Gta 5 data download for pc - Download - Action and adventure
- We couldn't find an account matching the login info you entered ✓ - Facebook Forum
1 response
I am assuming the sheet you want to transfer to has the three heading names in the order you stated.
Hope this helps.
Private Sub TransferRows()
Set s = Sheets("Sheet1")
Set t = Sheets("Sheet2")
Dim i
Dim b
i = 2
b = 1
Do Until IsEmpty(s.Range("A" & i))
If s.Range("A1") = t.Range("A1") And s.Range("C1") = t.Range("B1") And s.Range("D1") = t.Range("C1") Then
b = b + 1
t.Range("A" & b) = s.Range("A" & i)
t.Range("B" & b) = s.Range("C" & i)
t.Range("C" & b) = s.Range("D" & i)
End If
i = i + 1
Loop
t.Range("A1").Sort _
Key1:=t.Columns("A"), _
Header:=xlGuess
End Sub
Hope this helps.
Private Sub TransferRows()
Set s = Sheets("Sheet1")
Set t = Sheets("Sheet2")
Dim i
Dim b
i = 2
b = 1
Do Until IsEmpty(s.Range("A" & i))
If s.Range("A1") = t.Range("A1") And s.Range("C1") = t.Range("B1") And s.Range("D1") = t.Range("C1") Then
b = b + 1
t.Range("A" & b) = s.Range("A" & i)
t.Range("B" & b) = s.Range("C" & i)
t.Range("C" & b) = s.Range("D" & i)
End If
i = i + 1
Loop
t.Range("A1").Sort _
Key1:=t.Columns("A"), _
Header:=xlGuess
End Sub