Find first empty cell to Left within a range

Coelus

New Member
Joined
Sep 28, 2015
Messages
1
Hopefully the thread title isn't misleading for what I'm trying to do.

I have code that defines a range based on a value from another sheet; then duplicates that range, plus the cells to the left of that range, onto another sheet. So far, so good.

The problem is that now I need to look for the first cell to the left of the range with a value rather than just the cell to the left.

I know I need some kind of For Each Cell in Range statement, but I'm not sure how to fit it into what I have.

Sheets("Data2").Select

Cells(1, 1).Offset(1, Sheets("Results").Cells(2, 1)).Select
'Trouble below
Range(Sheets("Results").Cells(2, 6), Sheets("Results").Cells(20, 5)) = Range(ActiveCell.Offset(0, -1), ActiveCell.Offset(20, 0)).Value
'I'd like to look in each row in the ActiveCell range and find
'the next cell to the left with a value, then duplicate that to the range on "Results"


Range(Sheets("Results").Cells(2, 3), Sheets("Results").Cells(20, 3)) = Range(Cells(2, 1), Cells(20, 1)).Value
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,223,904
Messages
6,175,295
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