View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Need help programming some variable ranges

Sub test()
Dim Rng1 As Range
Dim Rng2 As Range

Set Rng1 = Selection.EntireRow
Set Rng2 = Range("A:N")

Application.Intersect(Rng1, Rng2).Select

End Sub

"havocdragon" wrote:

Hey all,

I am working with a variable amount of records on an excel file, and each of
them are selected differently, heres my solution however, I am having
difficulties with one peice of code...

ActiveCell.EntireRow.Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(-1, 0).Select
Range(Selection, Selection.End(xlUp)).Select

Lets say for example this selects A3:A6. What I want to do now is select all
the data in those Rows to the N column, however the goto current region
method wont work because a) there isnt data in every column and b) there is
data after the N column.

I have currently...

range(Selection, Columns("N:N")).select

However this will select everything from A:N.

Any ideas?