Offset The Column Of Each Selected Cell

mrscottjr

New Member
Joined
Jul 24, 2015
Messages
41
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hey all,

I'm hoping you might be able to assist. I'm using VBA and have gotten my code to look for a certain column header ("Carrots" in this case) and to select all the non-blank cells (cells with values "2" and "4"). I'm looking to offset the selection so that it doesn't select the "2" and "4" but rather selects the names in the first column ("Tom" and Louis"). I can't figure out how to offset the selection because I need to reference the "Carrots" column in order to know which "Names" I will need to select/copy. The values in the Carrots column don't matter to me - I just need to know how to copy only the associated names in the first column (Cells "A3" and "A5"). Is there a way to do this?


Name
PotatoesApplesCarrotsCandy
MARK311
TOM12
HANK221
LOUIS41
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I'm using VBA and have gotten my code to look for a certain column header ("Carrots" in this case) and to select all the non-blank cells (cells with values "2" and "4").
You don't need to offset, just use intersect with entire row and set the column holding the names.
VBA Code:
Intersect(Range("A:A"),Selection.EntireRow).Select
I've only used Selection and Select in order to demonstrate the syntax. In your actual code, selection is unnecessary and is unlikely to serve any real purpose. Setting the range to a variable, or working 'With' the range is preferable.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,472
Messages
6,125,011
Members
449,204
Latest member
tungnmqn90

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