How to have VBA find the last row of data, excluding rows with "" as data?

helpneeded2

Board Regular
Joined
Jun 25, 2021
Messages
110
Office Version
  1. 365
Platform
  1. Windows
I am trying to create a macro that will look for all rows of continuous data, until it reaches the first row without data, and then copy those rows.

My sheet can have up to 300 rows of data, but will normally only have about 150+. I have created a sheet with formulas for 300 rows, which pulls data in from a raw data sheet with a similar number of columns. If the value in column C of the raw data sheet is blank, then the value in column C of my processing sheet is "", and then all other cells for that row on the processing sheet will also be "".

I am using the current formula, but I think it is detecting the "" as containing data, so it is selecting data from all 300 rows, rather than just the rows that have data other than "".

Can someone please suggest a fix for this:

VBA Code:
Sub copyAll()
    Dim endOfRows As Long
    endOfRows = Range("C" & Rows.Count).End(xlUp).Row
    Range("B3").Resize(endOfRows - 2, 40).Select
    Selection.Copy
End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
How about:

VBA Code:
endOfRows =Activesheet.Range("A:A").Find("*", , xlValues, , xlByRows, xlPrevious).Row
 
Upvote 0
Solution
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,499
Members
449,089
Latest member
Raviguru

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