View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Magnivy Magnivy is offline
external usenet poster
 
Posts: 70
Default Macro to Specific Cells in a Range

Bob, thanks a lot for your help!

"Bob Phillips" wrote:

Sub selectcells()
Dim rng1 As Range
Dim rng2 As Range
Dim rng As Range

On Error Resume Next
Set rng1 = Range("A1:V1").SpecialCells(xlCellTypeConstants)
Set rng2 = Range("A1:V1").SpecialCells(xlCellTypeFormulas)
On Error GoTo 0
If rng1 Is Nothing And rng2 Is Nothing Then
MsgBox "No blank cells"
Else
Set rng = rng1
If rng1 Is Nothing Then
Set rng = rng2
ElseIf rng2 Is Nothing Then
Set rng = rng1
Else
Set rng = Union(rng1, rng2)
End If
Intersect(rng.EntireColumn, Range("A12:V12")).Select
End If


End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Magnivy" wrote in message
...
Hello,

I am trying to create a macro that would select specific cells within a
horizontal vector, so that I could perform an operation only on the

selected
cells. For example, I have two horizontal ranges, Range 1 is A1:V1 and

Range
2 is A12:V12. I would like to create a macro that would select the cells

in
Range 2 only for which the corresponding cells in Range 1 are non blanks,

so
that I could perform another operation on cells in Range 2 for which the
corresponding cells in Range 1 are non blanks. Any assistance with this

would
be greatly appreciated!

Magnivy