hello,
I have a weird thing happening with this code shown below.
This code is supposed to look in row 1 for a specific header name and then copy the entire column to another sheet. This code is working fine except for these 2 blocks. The first block of code copies the same column twice on the new sheet but it shouldn't because the header names are different. It copies "Current Odometer Reading Date" to columns Y and Z but it should only copy it to Y then the next block copy "Current Odometer Reading" to column Z. Y and Z are identical after I run this code.
Can anyone tell me what I'm missing here? I have 27 columns I use this code on and they all work fine, its just these 2 that are the problem.
I have a weird thing happening with this code shown below.
Code:
'Find "Current Odometer Reading Date" in Row 1
With Sheets(1).Rows(1)
Set t = .Find("Current Odometer Reading Date", lookat:=xlPart)
'If not found, present a message
If Not t Is Nothing Then
Columns(t.Column).EntireColumn.Copy _
Destination:=Sheets(2).Range("Y1")
Else: MsgBox "Current Odometer Reading Date Not Found"
End If
End With
'Find "Current Odometer Reading" in Row 1
With Sheets(1).Rows(1)
Set t = .Find("Current Odometer Reading", lookat:=xlPart)
'If not found, present a message
If Not t Is Nothing Then
Columns(t.Column).EntireColumn.Copy _
Destination:=Sheets(2).Range("Z1")
Else: MsgBox "Current Odometer Reading Not Found"
End If
End With
Can anyone tell me what I'm missing here? I have 27 columns I use this code on and they all work fine, its just these 2 that are the problem.
Last edited: