Copy cells if condition is met

Quasar Hunter

New Member
Joined
Oct 23, 2020
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Hi everyone,

I have 3 tables on the same sheet Table 1 (A4:E23), Table 2 (J5:M19) and Table 3 (J21:M35).
I want to copy data from Table 1 in columns B,C,D,E to first empty row in
table 2 if the value in column A is "TK2", and copy to table 3 if value is "TK3".

Thanks!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
If your tables have headers then Try this:
VBA Code:
Sub CopyBetweenTables()
Dim Lr1 As Long, Lr2 As Long

For i = 4 To 23
Lr1 = Range("J19").End(xlUp).Row + 1
Lr2 = Range("J35").End(xlUp).Row + 1
If Cells(i, 1).Value = "TK2" Then
Range("J" & Lr1 & ":M" & Lr1).Value = Range("B" & i & ":E" & i).Value
ElseIf Cells(i, 1).Value = "TK3" Then
Range("J" & Lr2 & ":M" & Lr2).Value = Range("B" & i & ":E" & i).Value
End If
Next i
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

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