select,cut and oaste cells

  • Thread starter Thread starter RobcPettit
  • Start date Start date
R

RobcPettit

Im selecting a cell, say range e2, then move down the column. when a cell = a
certain value I select the cell, then carry on down the column until i find a
cell containing a certain value then holding down the control key, select that
cell. Eventually I have several cells which I then cut and Paste else were. The
value is always the same. Can I do this using vba to make thins faster. So far
Im making range e2 the active cell, then using offset to move down the column.
I know how to select the cells if there all together, I just cant work out how
to select cells if there not continues, eg using the control key in the
program.hope this makes sense and somebody can advise.
Regards Robert
 
You would need to create a range and then select the entire range. For
example (untested):

Dim rng As Range, c As Range
Do Until c.Row = 1000 'depending on how many rows of data you have
c = c.Offset(1)
If c = 3.5 Then 'say
If rng Is Nothing Then
Set rng = c
Else
Set rng = Union(rng, c)
End If
End If
Loop
rng.Select
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top