Macro to copy data from various locations repeating down a list

dc007c0231

New Member
Joined
Dec 3, 2009
Messages
5
Morning all,

I need to produce a list from an imported PDF file in Excel. The list has multiple accounts on it showing what they have bought in a store. This results in some people having one line and some with 20 etc. I need all of this data in a clean list with all the relevant data added to the end columns. I have attached an image showing the template and what I need.

I need B10 copied to col U against each row of data (where there are transactions only), I need the blank cells under the dates populated with the date from above (only where there's a transaction) and the name and form as well (as per the colour coding). I could record a macro to do this for the first entry but I don't know how to repeat it down the entire sheet (8000 rows) which have different number of rows in each set of data.

Can anyone help please?
Thanks
James
 

Attachments

  • excel help.JPG
    excel help.JPG
    157.8 KB · Views: 11

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Public Sub ShopRecharges()

Dim sId As String
Dim sName As String
Dim sForm As String
Dim tDate As Variant
Dim lRow As Long
Dim tRow As Long

lRow = Cells(Rows.Count, "S").End(xlUp).Row
For tRow = 1 To lRow
If Cells(tRow, "B").MergeArea.Rows.Count > 1 And Cells(tRow, "B").Value <> "" Then
sId = Cells(tRow, "B").Value
sName = Cells(tRow, "D").Value
sForm = Cells(tRow + 2, "D").Value
ElseIf Cells(tRow, "E").Value <> "" And Cells(tRow, "E").Value <> "Code" Then
If Cells(tRow, "B").Value = "" Then
With Cells(tRow, "B")
.Value = tDate
.Resize(1, 2).Merge
.HorizontalAlignment = xlLeft
End With
Else
tDate = Cells(tRow, "B").Value
End If
Cells(tRow, "U").Resize(1, 3).Value = Array(sId, sName, sForm)
End If
Next tRow

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,912
Messages
6,122,204
Members
449,072
Latest member
DW Draft

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