I use the following VLOOKUP formula to add up the membership subscription payments in monthly worksheets labelled Nov, Dec, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct (a calendar year) in a ‘Members’ worksheet that shows who have paid their annual fee and also totals up monthly payments for that member from each of the monthly worksheets:
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Name of Member[/TD]
[TD]Subs Payment[/TD]
[TD]Total Payments[/TD]
[/TR]
[TR]
[TD]Name 1[/TD]
[TD]10.00[/TD]
[TD]30.00[/TD]
[/TR]
[TR]
[TD]Name 2[/TD]
[TD]10.00[/TD]
[TD]20.00[/TD]
[/TR]
</tbody>[/TABLE]
=VLOOKUP(B28,Nov!D:Z,17,FALSE)+VLOOKUP(B28,Dec!D:Z,17,FALSE)+VLOOKUP(B28,Jan!D:Z,17,FALSE)+VLOOKUP(B28,Feb!D:Z,17,FALSE)+VLOOKUP(B28,Mar!D:Z,17,FALSE)+VLOOKUP(B28,Apr!D:Z,17,FALSE)+VLOOKUP(B28,May!D:Z,17,FALSE)+VLOOKUP(B28,Jun!D:Z,17,FALSE)+VLOOKUP(B28,Jul!D:Z,17,FALSE)+VLOOKUP(B28,Aug!D:Z,17,FALSE)+VLOOKUP(B28,Sep!D:Z,17,FALSE)+VLOOKUP(B28,Oct!D:Z,17,FALSE)
I have produced VBA code in an attempt to copy the ‘Name’ and ‘Subs Payment’ columns from the ‘Members’ table to a new ‘Bagman’ worksheet and divide it into 3 equal length side-by-side columns so that it fits on one A4 sheet. This is what I want to achieve:
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Name[/TD]
[TD]Subs[/TD]
[TD][/TD]
[TD]Name[/TD]
[TD]Subs[/TD]
[TD][/TD]
[TD]Name[/TD]
[TD]Subs[/TD]
[/TR]
[TR]
[TD]Name 1[/TD]
[TD]10.00[/TD]
[TD][/TD]
[TD]Name 50[/TD]
[TD]5.00[/TD]
[TD][/TD]
[TD]Name 100[/TD]
[TD]10.00[/TD]
[/TR]
[TR]
[TD]Name 2[/TD]
[TD]10.00[/TD]
[TD][/TD]
[TD]Name 51[/TD]
[TD][/TD]
[TD][/TD]
[TD]Name 101[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
However, when the VLOOPUP cell value is copied to this new “Bagman” worksheet the value is shown as #N/A.
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Name[/TD]
[TD]Subs[/TD]
[TD][/TD]
[TD]Name[/TD]
[TD]Subs[/TD]
[TD][/TD]
[TD]Name[/TD]
[TD]Subs[/TD]
[/TR]
[TR]
[TD]Name 1[/TD]
[TD]#N/A[/TD]
[TD][/TD]
[TD]Name 50[/TD]
[TD]#N/A[/TD]
[TD][/TD]
[TD]Name 100[/TD]
[TD]#N/A[/TD]
[/TR]
[TR]
[TD]Name 2[/TD]
[TD]#N/A[/TD]
[TD][/TD]
[TD]Name 51[/TD]
[TD]#N/A[/TD]
[TD][/TD]
[TD]Name 101[/TD]
[TD]#N/A[/TD]
[/TR]
</tbody>[/TABLE]
I can overcome this problem by manually placing a member's subscription value in the relevant cell of the ‘Members’ worksheet (i.e. a specific value not derived from VLOOKUP) but I want to do this using the VLOOKUP procedure to ensure accuracy.
How can I stop this #N/A error from happening? Is there a way to convert the VLOOKUP cell value to a pure number, either before transferring to the ‘Bagman’ worksheet or during the process of transferring the data? It would be helpful if I just needed to modify the above code.
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Name of Member[/TD]
[TD]Subs Payment[/TD]
[TD]Total Payments[/TD]
[/TR]
[TR]
[TD]Name 1[/TD]
[TD]10.00[/TD]
[TD]30.00[/TD]
[/TR]
[TR]
[TD]Name 2[/TD]
[TD]10.00[/TD]
[TD]20.00[/TD]
[/TR]
</tbody>[/TABLE]
=VLOOKUP(B28,Nov!D:Z,17,FALSE)+VLOOKUP(B28,Dec!D:Z,17,FALSE)+VLOOKUP(B28,Jan!D:Z,17,FALSE)+VLOOKUP(B28,Feb!D:Z,17,FALSE)+VLOOKUP(B28,Mar!D:Z,17,FALSE)+VLOOKUP(B28,Apr!D:Z,17,FALSE)+VLOOKUP(B28,May!D:Z,17,FALSE)+VLOOKUP(B28,Jun!D:Z,17,FALSE)+VLOOKUP(B28,Jul!D:Z,17,FALSE)+VLOOKUP(B28,Aug!D:Z,17,FALSE)+VLOOKUP(B28,Sep!D:Z,17,FALSE)+VLOOKUP(B28,Oct!D:Z,17,FALSE)
I have produced VBA code in an attempt to copy the ‘Name’ and ‘Subs Payment’ columns from the ‘Members’ table to a new ‘Bagman’ worksheet and divide it into 3 equal length side-by-side columns so that it fits on one A4 sheet. This is what I want to achieve:
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Name[/TD]
[TD]Subs[/TD]
[TD][/TD]
[TD]Name[/TD]
[TD]Subs[/TD]
[TD][/TD]
[TD]Name[/TD]
[TD]Subs[/TD]
[/TR]
[TR]
[TD]Name 1[/TD]
[TD]10.00[/TD]
[TD][/TD]
[TD]Name 50[/TD]
[TD]5.00[/TD]
[TD][/TD]
[TD]Name 100[/TD]
[TD]10.00[/TD]
[/TR]
[TR]
[TD]Name 2[/TD]
[TD]10.00[/TD]
[TD][/TD]
[TD]Name 51[/TD]
[TD][/TD]
[TD][/TD]
[TD]Name 101[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Rich (BB code):
' Copy_"Members"_To_"Bagman" Macro
Sheet27.Select ' Members sheet
Range("C3", Range("B3").End(xlDown)).Select
Selection.Copy
Range("A1").Select
Sheet14.Select ' Bagman sheet
Columns("A:B").Select
ActiveSheet.Paste
Range("A1").Select
' Convert One Pair of Columns to Three (near) equal length Pairs of Columns
Dim lngR As Long
Dim lngC As Long
Dim lngHeaderRow As Long
Dim strCol As String
lngHeaderRow = 1
strCol = "A"
With Sheet14 ' Bagman sheet
lngR = .Cells(.Rows.Count, strCol).End(xlUp).Row - lngHeaderRow
lngC = .Cells(lngHeaderRow, .Columns.Count).End(xlToLeft).CurrentRegion.Columns.Count
'Copy headers
.Cells(lngHeaderRow, strCol).Resize(1, lngC).Copy .Cells(lngHeaderRow, strCol).Offset(0, lngC + 1)
.Cells(lngHeaderRow, strCol).Resize(1, lngC).Copy .Cells(lngHeaderRow, strCol).Offset(0, 2 * lngC + 2)
'Move data
.Cells(lngHeaderRow, strCol).Offset(1 + 2 * (lngR \ 3) + lngR Mod 3, 0).Resize(lngR \ 3, lngC).Cut .Cells(lngHeaderRow, strCol).Offset(1, 2 * lngC + 2)
.Cells(lngHeaderRow, strCol).Offset(1 + lngR \ 3 + IIf(lngR Mod 3 >= 1, 1, 0), 0).Resize(lngR \ 3 + IIf(lngR Mod 3 >= 1, 1, 0), lngC).Cut .Cells(lngHeaderRow, strCol).Offset(1, lngC + 1)
End With
Cells.EntireColumn.AutoFit
However, when the VLOOPUP cell value is copied to this new “Bagman” worksheet the value is shown as #N/A.
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Name[/TD]
[TD]Subs[/TD]
[TD][/TD]
[TD]Name[/TD]
[TD]Subs[/TD]
[TD][/TD]
[TD]Name[/TD]
[TD]Subs[/TD]
[/TR]
[TR]
[TD]Name 1[/TD]
[TD]#N/A[/TD]
[TD][/TD]
[TD]Name 50[/TD]
[TD]#N/A[/TD]
[TD][/TD]
[TD]Name 100[/TD]
[TD]#N/A[/TD]
[/TR]
[TR]
[TD]Name 2[/TD]
[TD]#N/A[/TD]
[TD][/TD]
[TD]Name 51[/TD]
[TD]#N/A[/TD]
[TD][/TD]
[TD]Name 101[/TD]
[TD]#N/A[/TD]
[/TR]
</tbody>[/TABLE]
I can overcome this problem by manually placing a member's subscription value in the relevant cell of the ‘Members’ worksheet (i.e. a specific value not derived from VLOOKUP) but I want to do this using the VLOOKUP procedure to ensure accuracy.
How can I stop this #N/A error from happening? Is there a way to convert the VLOOKUP cell value to a pure number, either before transferring to the ‘Bagman’ worksheet or during the process of transferring the data? It would be helpful if I just needed to modify the above code.