H
Howard
A fairly simple macro to lookup the date posted in cell B1 and for each matching date in the named range DataA column, return data in a non sequential
manner.
As below the data returned is column 3, 1, 4 & 8. This works okay but the final version has 11 columns to return in a similar "scatter gun" method.
In this case it would be columns in this order from the DataA column C:
D, G, R, S, W, AF, AG, Y, AD, N & AE.
Making eleven different offset copy lines seems a bit clunky, but it would be the easiest for me, as I don't know how to skip various column and then return back to get them without the individual copy offsets.
Then the next hurdle is to return the data to C10 through M10 and downward from there.
Thanks,
Howard
Option Explicit
Sub DataACopy()
Dim DataA As Range
Dim c As Range
Dim aDate As String
aDate = Range("B1").Value
Application.ScreenUpdating = False
For Each c In Range("DataA")
If c.Value = aDate Then
c.Offset(, 3).Copy
Sheets("Sheet2").Range("C100").End(xlUp).Offset(1, 0).PasteSpecial
c.Offset(, 1).Copy
Sheets("Sheet2").Range("D100").End(xlUp).Offset(1, 0).PasteSpecial
c.Offset(, 4).Copy
Sheets("Sheet2").Range("E100").End(xlUp).Offset(1, 0).PasteSpecial
c.Offset(, 8).Copy
Sheets("Sheet2").Range("F100").End(xlUp).Offset(1, 0).PasteSpecial
End If
Next
Application.ScreenUpdating = True
Application.CutCopyMode = False
End Sub
manner.
As below the data returned is column 3, 1, 4 & 8. This works okay but the final version has 11 columns to return in a similar "scatter gun" method.
In this case it would be columns in this order from the DataA column C:
D, G, R, S, W, AF, AG, Y, AD, N & AE.
Making eleven different offset copy lines seems a bit clunky, but it would be the easiest for me, as I don't know how to skip various column and then return back to get them without the individual copy offsets.
Then the next hurdle is to return the data to C10 through M10 and downward from there.
Thanks,
Howard
Option Explicit
Sub DataACopy()
Dim DataA As Range
Dim c As Range
Dim aDate As String
aDate = Range("B1").Value
Application.ScreenUpdating = False
For Each c In Range("DataA")
If c.Value = aDate Then
c.Offset(, 3).Copy
Sheets("Sheet2").Range("C100").End(xlUp).Offset(1, 0).PasteSpecial
c.Offset(, 1).Copy
Sheets("Sheet2").Range("D100").End(xlUp).Offset(1, 0).PasteSpecial
c.Offset(, 4).Copy
Sheets("Sheet2").Range("E100").End(xlUp).Offset(1, 0).PasteSpecial
c.Offset(, 8).Copy
Sheets("Sheet2").Range("F100").End(xlUp).Offset(1, 0).PasteSpecial
End If
Next
Application.ScreenUpdating = True
Application.CutCopyMode = False
End Sub