Need to copy/paste data columns based upon date

TsarMarkI

New Member
Joined
Aug 14, 2019
Messages
20
Good afternoon excel gurus!

Need some help with creating a VBA macro that will allow me to do the following:
- Sheet "Tracker" contains a date in B2 and data in range I5:I33
- Sheet "Data" contains all the dates for the month in range B2:AE2
I need help with a copy/paste macro that will copy the data from "Tracker" in I5:I33 to the corresponding date on "Data" that is in cell "B2" on the "Tracker" tab

For Example:
Date in B2 on "Tracker" tab is 12/4/19
All data in range I5:I33 on "Tracker" tab is copied
Macro finds the date 12/4/19 on "Data" tab in range B2:AE2
Data is pasted in corresponding column that matches that date.

Any help with this would be greatly appreciated!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
How about

VBA Code:
Sub test()
  Dim sh1 As Worksheet, sh2 As Worksheet, r As Range, f As Range
 
  Set sh1 = Sheets("Tracker")
  Set sh2 = Sheets("Data")
 
  If sh1.Range("B2").Value = "" Then
    MsgBox "put a date in B2"
    Exit Sub
  End If
 
  Set r = sh1.Range("I5:I33")
  Set f = sh2.Rows(2).Find(sh1.Range("B2").Value, , xlFormulas, xlWhole)
  If Not f Is Nothing Then
    f.Offset(1).Resize(r.Rows.Count, 1).Value = r.Value
    MsgBox "data copied"
  Else
    MsgBox "Date does not exists"
  End If

End Sub
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,813
Messages
6,127,026
Members
449,352
Latest member
Tileni

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top