Find the last value on the a row

mark692

Active Member
Joined
Feb 27, 2015
Messages
321
Office Version
  1. 2016
Platform
  1. Windows
hi guys i want to know the last value of a row like this on my table


ABCDEFG
1
2Table 1 in Sheet 1
320162017201820192020
4Apple 6,565.00 1,321.00 16,516.00 8,491.00
5Grapes 4,819.00 51,651.00 15,651.00 1,984.00
6Orange 8,191.00 151,651.00 1,561.00 89,459.00
7
8Table 2 in Sheet 2
9Apple 8,491.00
10Grape 1,984.00
11Orange 89,459.00
12

<tbody>
</tbody>
Sheet1
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Here is a vba solution

Code:
Option Explicit


Sub ABC()
    Dim s1 As Worksheet, s2 As Worksheet
    Set s1 = Sheets("Sheet1")
    Set s2 = Sheets("Sheet2")
    Dim r As Range, q As Range
    Dim i As Long, lr As Long, lr2 As Long, lc As Long
    lr = s1.Range("A" & Rows.Count).End(xlUp).Row
    Application.ScreenUpdating = False
    For i = 4 To lr
        lc = s1.Cells(i, Columns.Count).End(xlToLeft).Column
        lr2 = s2.Range("A" & Rows.Count).End(xlUp).Row
        Set r = s1.Cells(i, 1)
        Set q = s1.Cells(i, lc)
        Application.Union(r, q).Copy
        s2.Range("A" & lr2 + 1).PasteSpecial xlPasteValues
    Next i
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    MsgBox "Action complete"
End Sub
 
Upvote 0

Book1
ABCDEF
120162017201820192020
2Apple6,565.001,321.0016,516.008,491.00
3Grapes4,819.0051,651.0015,651.001,984.00
4Orange8,191.00151,651.001,561.0089,459.00
5
Sheet1



Book1
AB
1
2Apple8,491.00
3Grapes1,984.00
4Orange89,459.00
5
Sheet2


In B2 of Sheet2 enter and copy down:

=LOOKUP(9.99999999999999E+307,INDEX(Sheet1!$B$2:$XFD$4,MATCH(A2,Sheet1!$A$2:$A$4,0),0))
 
Upvote 0

Forum statistics

Threads
1,216,052
Messages
6,128,509
Members
449,455
Latest member
jesski

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