Insert data from different sheets into one

richard1234567891011

Board Regular
Joined
Feb 21, 2018
Messages
91
Hello Guys,

I have two similar tables in different sheets and I want them both in one sheet.

What do you think is the best way?

A macro? A formula?
And in case, what is the macro or formula?

This is the example:
Sheet: Aste

1574198711354.png


Sheet: Datio

1574198720918.png


Expected result:
Sheet: Aste+Datio

1574198736858.png


Thank you guys,
Kind regards.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
An error message appears?
What does the error message say?
 
Upvote 0
It appears this error message:
Screenshot 2019-11-29 at 19.09.42.png


With the Debug, I have in yellow this:
sh3.Range("A" & lr3 + 1).Resize(lr2, 9).Value = sh2.Range("A2").Resize(lr2, 9).Value
 
Upvote 0
Try this
VBA Code:
Sub Insert_data()
  Dim sh1 As Worksheet, sh2 As Worksheet, sh3 As Worksheet
  Dim lr1 As Long, lr2 As Long, lr3 As Long, wMax As Long, i As Long
  Set sh1 = Sheets("Aste")
  Set sh2 = Sheets("Datio")
  Set sh3 = Sheets("Master")
  sh3.Rows("5:" & Rows.Count).ClearContents
  lr1 = 5
  Do While sh1.Range("C" & lr1).Value <> ""
    lr1 = lr1 + 1
  Loop
  lr1 = lr1 - 1
  lr2 = 5
  Do While sh2.Range("C" & lr2).Value <> ""
    lr2 = lr2 + 1
  Loop
  lr2 = lr2 - 5
  sh3.Range("A5").Resize(lr1 - 4, 9).Value = sh1.Range("A5").Resize(lr1 - 4, 9).Value
  lr3 = sh3.Range("C" & Rows.Count).End(xlUp).Row
  wMax = sh3.Range("C" & lr3).Value
  sh3.Range("A" & lr3 + 1).Resize(lr2, 9).Value = sh2.Range("A5").Resize(lr2, 9).Value
  For i = lr3 + 1 To sh3.Range("C" & Rows.Count).End(xlUp).Row
    sh3.Range("C" & i).Value = sh3.Range("C" & i).Value + wMax
  Next
End Sub
 
Upvote 0
I'm glad to help you. I appreciate your kind comments.
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,538
Members
449,038
Latest member
Guest1337

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