Finding and copying from data file

jpen

Active Member
Hi all,

I want to copy data from a data file to another file.

First I have to find the name in the data file (QQQQ, XXXX, YYYY) and then copy the data above the name. See example.
CLIPBORD.xls
ABCD
11a1355.50%
2a2181.50%
32b1538.70%
4b2296.20%
5b3584.90%
6b4378.70%
7b5270.50%
83c1687.30%
9c2687.90%
10c3386.80%
11----------
12AverageQQQQ3.469.60%
13
141a1191.10%
15----------
16AverageXXXX191.10%
17
181a1550.00%
19a20.0!
20a3590.00%
21a4333.30%
222b1383.30%
23b2383.30%
243c1560.00%
25c2641.70%
26c3633.30%
274d15100.00%
28d2366.70%
29----------
30AverageYYYY3.8!69.20%
CLIPBORD

For QQQQ there are 10 rows of data.
For XXXX there are 1 rows of data.
For YYYY there are 11 rows of data.

These data I want to copy to the other file where I have worksheets called QQQQ, XXXX and YYYY.

Has anyone a idea how to solve this problem.

JH

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Are there always 10,1 and 11 rows of data or can the number of rows vary?

No the number of rows vary.

JH

Is there only one instance of each type. ie just one QQQQ, XXXX and YYYY?

hi -
try this one.
data in first sheet, other sheets QQQQ,XXXX,YYYY to the right

Code:
``````Sub sample()
On Error Resume Next
Dim a
Dim i, ii As Long
ii = Sheets(1).Range("b" & Rows.Count).End(xlUp).Row
For i = 2 To Sheets.Count
With Sheets(1).Range("b1:b" & ii)
Set c = .Find(Sheets(i).Name, , , xlWhole)
If Not c Is Nothing Then
a = c.Offset(, 1).End(xlUp).Row
Range("a" & a & ":d" & c.Row).Copy Sheets(i).Range("a" & Rows.Count).End(xlUp).Offset(1)
End If
End With
Next
End Sub``````

Replies
1
Views
95
Replies
0
Views
42
Replies
1
Views
294
Replies
3
Views
3K
Replies
1
Views
157

1,217,383
Messages
6,136,244
Members
450,001
Latest member
KWeekley08

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.

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

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