Find Last Cell greater than 0 in Column and Copy Range

buzz71023

Active Member
Joined
May 29, 2011
Messages
295
Office Version
  1. 2016
Platform
  1. Windows
Good morning all,
I thought this would be an easy research and implement but the few examples I have found, just didn't work.
I have data in range L1 to Q100, all with formula calculations.
I need to find the last cell in column "O" greater than zero and copy the range L1 to Q(last row greater than zero).

Thank you in advance for any time you invest in this and all help is greatly appreciated.

BT
 

Attachments

  • Screenshot 2023-12-06 095530.png
    Screenshot 2023-12-06 095530.png
    23.7 KB · Views: 10

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Do you still have Excel 2016? Because with newer version the answer would change
 
Upvote 0
How about in Q1 copied down
Excel Formula:
=IF(ROW()=LOOKUP(2,1/($O$1:$O$100>0),ROW($O$1:$O$100)),L$1,"")
 
Upvote 0
How about this?:

For this array formula to work in excel 2016 you will have to select from A1 to F100 (or any range with the same size as your data) then edit and past the formula and hit Ctrl+Shift+Enter.

Libro1
ABCDEFGHIJKLMNOPQ
1667231653534667231653534
2487068644794487068644794
374931504357493150435
4378399376370378399376370
5711840106658711840106658
6329835381066329835381066
77526457335775264573357
8143640418340143640418340
9568059342226568059342226
10698535344077698535344077
1147731669374773166937
12522922343319522922343319
13973983738891973983738891
148563745892685637458926
151918388978919183889789
16403727473
17238191691
18303063434
19115795649
207560222445
21761890754
22653788567
231051210097
2476376219
252574439
263368381848
271093281856
286777895355
29413822411
302692332541
31123695167
3284506566
337550418046
349333419839
351156222025
366258576324
376468158391
38244652151
39579273551
40381168408
414081351720
425193246726
43507727193
446032776411
451177251524
4666355928
47937114079
4810011473428
494083691748
50951352196
51481415333
52287642270
533887734981
545425368017
551845268549
56275713673
57348812439
586377417496
5965413610054
608741759546
617439443821
622621468456
636345657775
644366742442
656790997385
6660641003085
67121814798
684297961193
69292502224
70409967117
7187427093100
728096381392
737262559876
746650179380
756891416195
76932199565
77961890456
78321784788
795140202818
808111331134
818179159669
827331276393
839856644628
845499504782
85863792295
869964366589
8765249595
889327709855
894279126618
90130768411
915264138111
929268212517
934551381475
949741658884
956925219766
964350808462
977192389320
98932626132
99157523752
10035363365
Hoja1
Cell Formulas
RangeFormula
A1:F15A1=OFFSET($L$1,0,0,MAX(ISNUMBER($O$1:$O$100)*ROW($O$1:$O$100)),6)
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
How about in Q1 copied down
Excel Formula:
=IF(ROW()=LOOKUP(2,1/($O$1:$O$100>0),ROW($O$1:$O$100)),L$1,"")
Apologies, I probably didn't specify the "copy" function I am needing.
I am going to have to copy the whole range of data (L1 to Q last greater than zero row) and paste it into another database.
Wont that have to be a VBA function.
 
Upvote 0
There is probably a much better way to do this but after a couple more hours of research this is what I came up with.
I appreciate your input on the formulas above. :)

VBA Code:
Dim LastRNG As Range, StartRNG As Range, CopyRNG As Range

    Dim B As Long, BB As Long
    BB = Cells(Rows.Count, "O").End(xlUp).Row
    For B = BB To 1 Step -1
        If Cells(B, 1).Value = 0 Then
            Cells(B, 1).Offset(-1, 16).Select
        End If
    Next

Set LastRNG = ActiveCell
Set StartRNG = Range("L1")
Set CopyRNG = Range(StartRNG, LastRNG)

CopyRNG.Copy
 
Upvote 0
Solution
Glad you sorted it & thanks for letting us know.
 
Upvote 0
There is probably a much better way to do this ..
If you wanted to investigate that could you clarify the requirement?

Post #1 said
I need to find the last cell in column "O" greater than zero
Code in post #8 finds last cell in column A greater than zero.

Could we see some sample data that includes column A down past the last non-zero value? (You could hide columns B:K)
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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