VBA - copying range to different sheets based on cell values

naveen_jaina

New Member
Joined
Aug 22, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I am trying to think of a way to copy a range of data from one sheet to another, based on the common value (ID) within the columns in both sheets. Although the attached image shows a small amount of data, I'm dealing with multiple sheets and a large number of rows, so prefer a VBA coding to get the output. What's the best method to approach such data manipulation? Does the loop work best in this kind of situation?

**Sorry, I haven't been able to use xl2bb to generate mini-sheet, that's why uploaded the image here again. **

Thank you!!!
 

Attachments

  • TestDate.JPG
    TestDate.JPG
    95.3 KB · Views: 2

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Share the sample sheet along with result for easy understanding about your requirement
 
Upvote 0
Share the sample sheet along with result for easy understanding about your requirement

I think the xl2bb worked this time. Here's the sample data.

Test.xlsx
ABCDEFGHIJKLMNOPQ
1
2Table 1 in Sheet 1Input
3#MonTueWedThuFriSatSunMonTueWedThuFriSatSun
41Y 515515515515515515515515515
52800830515515515515515515515515
63900900730615615730730730Y 615
7
8
9#MonTueWedThuFriSatSunMonTueWedThuFriSatSun
101
11Table 2 in Sheet 1
12
13
142
15
16
17
183
19
20
21
22
23
24#MonTueWedThuFriSatSunMonTueWedThuFriSatSun
251Y 515515515515515515515515515
26Output Table 2 in Sheet 1
27
28
292830830515515515515515515515515
30
31
32
333900900730615615730730730Y 615
34
35
36
Sheet1
 
Upvote 0
Try this . Now the whole table will work if you input Table serial number without gap if you want.

Book1
ABCDEFGHIJKLMNOPQ
1
2Table 1 in Sheet 1Input
3#MonTueWedThuFriSatSunMonTueWedThuFriSatSun
41Y 515515515515515515515515515
52800830515515515515515515515515
63900900730615615730730730Y 615
7
8
9#MonTueWedThuFriSatSunMonTueWedThuFriSatSun
101
11Table 2 in Sheet 1
12
13
142
15
16
17
183
19
20
21
22
23
24#MonTueWedThuFriSatSunMonTueWedThuFriSatSun
251Y 515515515515  515515515515515  
26Output Table 2 in Sheet 1              
27              
28              
292800830515515515  515515515515515  
30              
31              
32              
333  900900730615615  730730730Y 615
34              
35              
36              
Sheet1
Cell Formulas
RangeFormula
D25:Q36D25=IFERROR(IF(VLOOKUP($C25,$A$4:$O$6,COLUMNS($C$24:D$24),0)=0,"",VLOOKUP($C25,$A$4:$O$6,COLUMNS($C$24:D$24),0)),"")
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,181
Members
449,071
Latest member
cdnMech

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