Transferring data from one list to another

Ivn68

Board Regular
Joined
Aug 21, 2015
Messages
82
I have a dates on sheet2
DateHours WorkedHours off
08/01/2444
08/05/2452
08/07/24100

I want to be able to find the date on sheet1 and then enter the corresponding values underneath the date
date8/1/20248/2/20248/3/20248/4/20248/5/20248/6/20248/7/2024
hours
off
date8/8/20248/9/20248/10/20248/11/20248/12/20248/13/20248/14/2024
hours
off
date8/15/20248/16/20248/17/20248/18/20248/19/20248/20/20248/21/2024
hours
hours
off

so ideally I would enter all the info onto the list as the year goes on and then I would like to hit a button and it will transfer all the info onto sheet1. So the list will grow

thanks for any help
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Presuming top left 'Date' cell in each table is in cell A1
In Sheet1 in cell B2 enter
Excel Formula:
=IFERROR(INDEX(Sheet2!$B:$B,MATCH(B2,Sheet2!$A:$A,0)),"")
In cell B3 enter
Excel Formula:
=IFERROR(INDEX(Sheet2!$C:$C,MATCH(B2,Sheet2!$A:$A,0)),"")

Select B2&B3 and copy, select the range B2-H3 and paste. Now copy all of the B2-H3 range and copy, now paste in B5 and B8

01/08/2024​
02/08/2024​
03/08/2024​
04/08/2024​
05/08/2024​
06/08/2024​
07/08/2024​
hours
4​
5​
10​
off
4​
2​
0​
date
08/08/2024​
09/08/2024​
10/08/2024​
11/08/2024​
12/08/2024​
13/08/2024​
14/08/2024​
hours
off
date
15/08/2024​
16/08/2024​
17/08/2024​
18/08/2024​
19/08/2024​
20/08/2024​
21/08/2024​
hours
off
 
Upvote 0
Presuming top left 'Date' cell in each table is in cell A1
In Sheet1 in cell B2 enter
Excel Formula:
=IFERROR(INDEX(Sheet2!$B:$B,MATCH(B2,Sheet2!$A:$A,0)),"")
In cell B3 enter
Excel Formula:
=IFERROR(INDEX(Sheet2!$C:$C,MATCH(B2,Sheet2!$A:$A,0)),"")

Select B2&B3 and copy, select the range B2-H3 and paste. Now copy all of the B2-H3 range and copy, now paste in B5 and B8

01/08/2024​
02/08/2024​
03/08/2024​
04/08/2024​
05/08/2024​
06/08/2024​
07/08/2024​
hours
4​
5​
10​
off
4​
2​
0​
date
08/08/2024​
09/08/2024​
10/08/2024​
11/08/2024​
12/08/2024​
13/08/2024​
14/08/2024​
hours
off
date
15/08/2024​
16/08/2024​
17/08/2024​
18/08/2024​
19/08/2024​
20/08/2024​
21/08/2024​
hours
off
Apologies,
In B2 enter
Excel Formula:
=IFERROR(INDEX(Sheet2!$B:$B,MATCH(B1,Sheet2!$A:$A,0)),"")
In B3 enter
Excel Formula:
=IFERROR(INDEX(Sheet2!$C:$C,MATCH(B1,Sheet2!$A:$A,0)),"")
 
Upvote 0
that doesn't work for me because I may have info already in the cell
sheet 2 is like an adjustment
thanks

it needs to be something i can like activate after i enter the adjustments
 
Upvote 0
something like this

Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer


b = Range("B4:B365").Rows.Count


For a = 4 To b
c = Sheets("PTO Adustments").Cells(2, a)
For d = 9 To 221
If c = ActiveSheet.Cells(3, d).Value Then
ActiveSheet.Cells(3, d + 1).Value = Sheets("PTO Adustments").Cells(3, a)
ActiveSheet.Cells(3, d + 2).Value = Sheets("PTO Adustments").Cells(4, a)
End If
Next d
next a

having problems with which sheet im dealing with in the vba




Next a
 
Upvote 0
Perhaps something like the below:
VBA Code:
Sub Test()
  Dim ws1 As Worksheet, ws2 As Worksheet
  Dim rCell As Range, fRng As Range
  Dim fDate As Date
  
  Set ws1 = Sheets("Sheet1")
  Set ws2 = Sheets("Sheet2")
  
  For Each rCell In ws2.Range("A2:A" & ws2.Range("A" & Rows.Count).End(xlUp).Row)
    fDate = rCell
    Set fRng = ws1.Cells.Find(fDate)
    If Not fRng Is Nothing Then
      fRng.Offset(1).Resize(2) = Application.Transpose(rCell.Offset(, 1).Resize(, 2))
    End If
  Next rCell
End Sub
 
Upvote 0
Should probably update the below:
VBA Code:
Set fRng = ws1.Cells.Find(fDate)
With:
VBA Code:
Set fRng = ws1.Cells.Find(fDate, , xlValues, xlWhole)
Making the code:
VBA Code:
Sub Test()
  Dim ws1 As Worksheet, ws2 As Worksheet
  Dim rCell As Range, fRng As Range
  Dim fDate As Date
  
  Set ws1 = Sheets("Sheet1")
  Set ws2 = Sheets("Sheet2")
  
  For Each rCell In ws2.Range("A2:A" & ws2.Range("A" & Rows.Count).End(xlUp).Row)
    fDate = rCell
    Set fRng = ws1.Cells.Find(fDate, , xlValues, xlWhole)
    If Not fRng Is Nothing Then
      fRng.Offset(1).Resize(2) = Application.Transpose(rCell.Offset(, 1).Resize(, 2))
    End If
  Next rCell
End Sub
 
Upvote 0
I am wondering if your dates are actual dates, are you able to use the XL2BB add in to display the data you are working with?

Are your dates - actual dates in the cell/ the result of a formula or just text strings?
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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