Relative cell reference selecting enitre row and entire column?

Lil2606

Board Regular
Joined
Jan 29, 2019
Messages
79
Hi all,

I literally started learning VBA 3 days ago, using excel-pratique's VBA course but as I'm trying to be thorough I started to make a "dictionary" and I'm writing up the different selections that are possible.

Could someone send me a working code for: Select entire Row AND entire Column, 1 Row down AND 1 Column to the right from the reference cell A1 , and explain a bit, why

---ActiveCell.Offset(1, 1).Range("1:1, A:A").Select--- doesn't work (application defined or object defined error), and how does their code work?

Thank you very much for the help!!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
First of all there is no need to select cells to work with them so the code below highlights the ranges.
You can use union to join the ranges . There are other ways to achieve the result.


Obviously ask about anything you don't understand.

Rich (BB code):
Sub HighlightRow()
    Dim xRng As Range
    'Declare the variable
    Set xRng = ActiveCell.Offset(1, 1)
    ' assign the cell to the variable
    Union(xRng.EntireRow, xRng.EntireColumn).Interior.ColorIndex = 6
    ' use Union to join the ranges
End Sub
 
Upvote 0
Hi, thank you for your reply but why is it not necessary to select cells or ranges to work with them? Do I need to select them if I want to copy them?
 
Upvote 0
No you don't need to select to copy and the big issue is it slows your code down dramatically as well as screen flicker. You also can't select anything not on the active sheet.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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