D
Doug
I have been using this macro to replace data back into columns 1-7 after I do
an import update from the web. It matches data in columns 1-7 up with respect
to column O between the old and new sheet data. I have made some changes
since I discovered the advantages of Vlookup and am hoping to find out how to
keep data in columns 1-7 with respect to column O. Right now when I do an
import the Vlookup rows shift, but the rows in columns 1-7 remain the same.
How can I make them shift with the other rows? I hope this makes sense.
Dim myCell As Range
Dim myNewRng As Range
Dim NewSheet As Worksheet
Dim OldSheet As Worksheet
Dim res As Variant
Set NewSheet = Workbooks("Doug's Research.xlsm").Worksheets("Screener")
Set OldSheet = Workbooks("Prior Screen.xlsm").Worksheets("Screener")
With NewSheet
Set myNewRng = .Range("O3", .Cells(.Rows.Count, "O").End(xlUp))
For Each myCell In myNewRng.Cells
If Not IsEmpty(myCell.Value) Then
res = Application.Match(myCell.Value, OldSheet.Range("O:O"), 0)
If IsError(res) Then
'not match, what should happen?
Else
..Cells(myCell.Row, "A").Resize(1, 7).Value _
= OldSheet.Cells(res, "A").Resize(1, 7).Value
End If
End If
Next myCell
End With
an import update from the web. It matches data in columns 1-7 up with respect
to column O between the old and new sheet data. I have made some changes
since I discovered the advantages of Vlookup and am hoping to find out how to
keep data in columns 1-7 with respect to column O. Right now when I do an
import the Vlookup rows shift, but the rows in columns 1-7 remain the same.
How can I make them shift with the other rows? I hope this makes sense.
Dim myCell As Range
Dim myNewRng As Range
Dim NewSheet As Worksheet
Dim OldSheet As Worksheet
Dim res As Variant
Set NewSheet = Workbooks("Doug's Research.xlsm").Worksheets("Screener")
Set OldSheet = Workbooks("Prior Screen.xlsm").Worksheets("Screener")
With NewSheet
Set myNewRng = .Range("O3", .Cells(.Rows.Count, "O").End(xlUp))
For Each myCell In myNewRng.Cells
If Not IsEmpty(myCell.Value) Then
res = Application.Match(myCell.Value, OldSheet.Range("O:O"), 0)
If IsError(res) Then
'not match, what should happen?
Else
..Cells(myCell.Row, "A").Resize(1, 7).Value _
= OldSheet.Cells(res, "A").Resize(1, 7).Value
End If
End If
Next myCell
End With