Copy cell values from row into columns

ilsley_excel

Board Regular
Joined
Mar 5, 2015
Messages
54
Office Version
  1. 2010
Platform
  1. Windows
Hi,

I am trying to copy dates and amounts (£) from each client row and paste them into column format in a summary table. Each date and amount (£) refers to a card transaction. The verbose table (see VerboseTable.jpg screenshot) holds up to 10 transactions, i.e. up to 10 dates and 10 amounts (3).

Each row represents a client and all their corresponding card transactions (see VerboseTable.jpg screenshot).

I want to create a routine that looks through this table and just copies the client number, client name and any existing card transactions they have into a summary table (see FinalSummaryTable.jpg).

I hope that makes sense!

Any ideas please?

Thanks.
 

Attachments

  • FinalSummaryTable.jpg
    FinalSummaryTable.jpg
    51.8 KB · Views: 9
  • VerboseTable.jpg
    VerboseTable.jpg
    98.5 KB · Views: 8

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: HELP NEEDED: Copy cell values from row into columns
There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
I'm bumping this up.

Ideally looking for an Excel VBA solution if possible?

Thanks.
 
Upvote 0
Yes, it would.

This is the verbose table of card transactions:

SampleCardTransactions.xlsx
ABCDEFGHIJKLMNOPQRSTUV
1Client NoClient NameDate1Amount1Date2Amount2Date3Amount3Date4Amount4Date5Amount5Date6Amount6Date7Amount7Date8Amount8Date9Amount9Date10Amount10
2QIS00183John07/03/202310009/03/202325012/03/2023325
3QIS00184Mark
4QIS00185Helen
5QIS00186May
6QIS00187Jane19/04/2023450
7QIS00188Lisa
8QIS00189Sarah
9QIS00190Harold
10QIS00191Ben
11QIS00192Kate
12QIS00193Jackie
13QIS00194Mike
14QIS00195Maria09/05/202340011/05/2023100012/05/2023550
VerboseTable


This is the output table I need:

SampleCardTransactions.xlsx
ABCD
2QIS00183John07/03/2023£100
3QIS00183John09/03/2023£250
4QIS00183John12/03/2023£325
5QIS00187Jane19/04/2023£450
6QIS00195Maria09/05/2023£400
7QIS00195Maria11/05/2023£1,000
8QIS00195Maria12/05/2023£550
FinalSummaryTable


Any ideas?
 
Last edited:
Upvote 0
Try the following on a copy of your workbook.
VBA Code:
Option Explicit
Sub ilsley()
    Dim ws1 As Worksheet, ws2 As Worksheet
    Set ws1 = Worksheets("VerboseTable")
    Set ws2 = Worksheets("FinalSummaryTable")
    
    Dim LRow As Long, n As Long, r As Range, a, b
    LRow = ws1.Cells(Rows.Count, 1).End(xlUp).Row
    Set r = ws1.Range("A1").CurrentRegion.Offset(1).Resize(LRow - 1)
    n = WorksheetFunction.CountA(r.Offset(, 2)) / 2
    
    a = r
    ReDim b(1 To n, 1 To 4)
    Dim i As Long, j As Long, k As Long
    k = 0
    For i = 1 To UBound(a, 1)
        For j = 3 To UBound(a, 2) - 1 Step 2
            If a(i, j) <> "" Then
                k = k + 1
                b(k, 1) = a(i, 1): b(k, 2) = a(i, 2)
                b(k, 3) = a(i, j): b(k, 4) = a(i, j + 1)
            End If
        Next j
    Next i
    
    ws2.Range("A2").Resize(UBound(b, 1), 4).Value = b
End Sub
 
Upvote 0
Solution
Try the following on a copy of your workbook.
VBA Code:
Option Explicit
Sub ilsley()
    Dim ws1 As Worksheet, ws2 As Worksheet
    Set ws1 = Worksheets("VerboseTable")
    Set ws2 = Worksheets("FinalSummaryTable")
   
    Dim LRow As Long, n As Long, r As Range, a, b
    LRow = ws1.Cells(Rows.Count, 1).End(xlUp).Row
    Set r = ws1.Range("A1").CurrentRegion.Offset(1).Resize(LRow - 1)
    n = WorksheetFunction.CountA(r.Offset(, 2)) / 2
   
    a = r
    ReDim b(1 To n, 1 To 4)
    Dim i As Long, j As Long, k As Long
    k = 0
    For i = 1 To UBound(a, 1)
        For j = 3 To UBound(a, 2) - 1 Step 2
            If a(i, j) <> "" Then
                k = k + 1
                b(k, 1) = a(i, 1): b(k, 2) = a(i, 2)
                b(k, 3) = a(i, j): b(k, 4) = a(i, j + 1)
            End If
        Next j
    Next i
   
    ws2.Range("A2").Resize(UBound(b, 1), 4).Value = b
End Sub

This worked perfectly. Sorry for the late reply!

Thanks!
 
Upvote 0

Forum statistics

Threads
1,215,135
Messages
6,123,241
Members
449,093
Latest member
Vincent Khandagale

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