VBA to Select Cells???

julia55

Board Regular
Joined
Dec 2, 2010
Messages
73
I am trying to figure out why this macro isn't working. I am trying to have it look at the value of the cell below and if it is blank then copy only the active cell. If it is not blank then I want it to select from the active cell to the end of the row (which will vary). Here is the code I have so far. It works to select the single cell, but not on the selection to the end. PLEASE HELP!

Code:
If IsNull(ActiveCell.Offset(1, 0).Value) = True Then
        ActiveCell.Copy
        ElseIf IsNull(ActiveCell.Offset(1, 0).Value) = False Then Range(ActiveCell, Selection.End(xlDown)).Copy
    End If
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
A cell can never contain the value Null.

Code:
    If IsEmpty(ActiveCell.Offset(1, 0).Value) Then
        ActiveCell.Copy
    Else
        Range(ActiveCell, ActiveCell.End(xlDown)).Copy
    End If
 
Upvote 0
You're welcome, happy to help.
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,813
Members
452,945
Latest member
Bib195

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