View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Selecting Separate Columns in VBA

My code DOESN'T require you to select the first column - it is all based on the active cell.

A lot of your code is bad:

This dimensionsw myR and x as variants:
Dim myR, x%, inputcells As Range


This sets the value of x to the activecell's value, not to the cell itself:
x = ActiveCell


So, if the activecell's value is 100, the search is started 100 rows down from the activecell...

Set inputcells = Range("A70")
Do Until inputcells(x, 2) = "~*"
x = x + 1
Loop


And since x is not a range object, this won't work:

Range(myR, x - 1).Select


Not sure what it is that you want to do beyond what I had shown....

HTH,
Bernie
MS Excel MVP


wrote in message ups.com...
Bernie,
That is really quite nice. However it requires the first column to be
selected before it is run - you cannot simply activate cell B70 - it
requires the range of cells B70:B85 to be selected in order to do this.
Here is my attempt at a correction - however I'm getting an
overflow...any suggestions?

Dim myR, x%, inputcells As Range
Dim myRow As Long

Set myR = ActiveCell
x = ActiveCell
Set inputcells = Range("A70")
Do Until inputcells(x, 2) = "~*"
x = x + 1
Loop

myRow = myR.EntireColumn.Find("~*", After:=myR, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext).Row
Range(myR, x - 1).Select